c++ - Perforce 的 C++ P4API 是线程安全的吗?

标签 c++ perforce

简单的问题 - Perforce 提供的 C++ API 是线程安全的吗?文档中没有提及它。

“线程安全”是指来自客户端的服务器请求。显然,如果我有多个线程试图在同一个连接上设置客户端名称等,就会出现问题。

但是给定一个连接对象,我可以让多个线程获取更改列表、获取状态、通过 p4 映射转换文件等吗?

最佳答案

迟到的答案,但是......来自release notes他们自己:

Known Limitations

      The Perforce client-server protocol is not designed to support
      multiple concurrent queries over the same connection. For this
      reason, multi-threaded applications using the C++ API or the
      derived APIs (P4API.NET, P4Perl, etc.) should ensure that a
      separate connection is used for each thread or that only one
      thread may use a shared connection at a time.

看起来客户端对象没有线程亲和性,所以为了在线程之间共享连接,只需要使用互斥体来序列化调用。

关于c++ - Perforce 的 C++ P4API 是线程安全的吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2837222/

相关文章:

diff - 如何应用 Perforce 补丁?

bitbucket - 如何将现有的 Git-p4 存储库迁移到 LFS

c++ - 为什么必须使用 'typename' 和 '::type' 前缀/后缀调用所有 type_traits 类?

c++ - 动态内存分配 C++

c++ - 目标文件和共享目标文件之间的关系

c++ - 连接 2 个 char* 会产生奇怪的结果

c++ - Qt 序列化,非成员 QDataStream & operator<<

p4diff和p4diff2之间的区别

python - 尝试使用 code_swarm 但我在 osx 上使用 perforce 时遇到了一些 python 脚本问题

python - bash shellshock 更新导致脚本行为不同