是 Perforce 的 C++ P4API线程安全?
简单的问题 - Perforce 提供的 C++ API 是线程安全的吗?文档中没有提及它。
我所说的“线程安全”是指来自客户端的服务器请求。显然,如果我有多个线程尝试在同一连接上设置客户端名称等,则会出现问题。
但是给定一个连接对象,我可以有多个线程来获取更改列表、获取状态、通过 p4 映射翻译文件等吗?
Simple question - is the C++ API provided by Perforce thread-safe? There is no mention of it in the documentation.
By "thread-safe" I mean for server requests from the client. Obviously there will be issues if I have multiple threads trying to set client names and such on the same connection.
But given a single connection object, can I have multiple threads fetching changelists, getting status, translating files through a p4 map, etc.?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
迟到的答案,但是...来自发行说明他们自己:
客户端对象看起来并不具有线程关联性,因此为了在线程之间共享连接,只需使用互斥体来序列化调用。
Late answer, but... From the release notes themselves:
It does not look like the client object has thread affinity, so in order to share a connection between threads, one just has to use a mutex to serialize the calls.
如果文档没有提到它,那么它就不安全。
使某些东西在任何意义上都是线程安全的通常很困难,并且可能会因为添加锁而导致性能损失。经历了这个麻烦然后不在文档中提及它是没有意义的。
If the documentation doesn't mention it, then it is not safe.
Making something thread-safe in any sense is often difficult and may result in a performance penalty because of the addition of locks. It wouldn't make sense to go through the trouble and then not mention it in the documentation.