简单的问题 - 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/