[英]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.