[英]Is Perforce's C++ P4API thread-safe?
简单的问题 - Perforce线程安全提供的C ++ API是什么? 文档中没有提到它。
“线程安全”我的意思是来自客户端的服务器请求。 显然,如果我有多个线程试图在同一个连接上设置客户端名称,那么就会出现问题。
但是给定一个连接对象,我可以让多个线程获取更改列表,获取状态,通过p4映射翻译文件等吗?
迟到的答案,但......从发行说明本身:
已知限制
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.
它看起来不像客户端对象具有线程亲和性,因此为了共享线程之间的连接,只需使用互斥锁来序列化调用。
如果文档没有提到它,那么它就不安全了。
在任何意义上使线程安全都很困难,并且由于增加了锁定,可能会导致性能下降。 通过麻烦然后在文档中没有提到它是没有意义的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.