简单的问题-- Perforce提供的C++应用程序接口是线程安全的吗?文档中没有提到这一点。
我所说的“线程安全”指的是来自客户端的服务器请求。显然,如果我有多个线程试图在同一连接上设置客户端名称等,就会出现问题。
但是给定一个单一的connection对象,我可以有多个线程来获取变更列表、获取状态、通过p4映射转换文件等等吗?
发布于 2012-05-11 05:52:20
回答晚了但是..。从release notes本身:
已知限制
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.它看起来不像客户端对象具有线程亲和性,因此为了在线程之间共享连接,只需使用互斥锁来序列化调用。
发布于 2010-05-15 05:38:59
如果文档中没有提到它,那么它是不安全的。
让某些东西在任何意义上都是线程安全的通常是困难的,并且可能会因为添加了锁而导致性能损失。经历了这些麻烦,然后在文档中没有提到它,这是没有意义的。
https://stackoverflow.com/questions/2837222
复制相似问题