开发者

Is Perforce's C++ P4API thread-safe?

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开发者_JAVA百科 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.?


Late answer, but... From the release notes themselves:

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.

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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜