c – 為什麼is_lock_free是一個成員函式?
我正在尋找一個為什麼需要的實際例項.
section 29.4Lock-free property
The ATOMIC_…_LOCK_FREE macros indicate the lock-free property of the
corresponding atomic types, with the signed and unsigned variants
grouped together. The properties also apply to the corresponding
(partial) specializations of the atomic template. A value of 0
A value of 1 indicates
A value of 2 indicates thatthe types are always lock-free.
ofollow,noindex" target="_blank">C++ atomic paper n2427 說明了以下原因:
… The proposal provides run-time lock-free query functions ratherthan compile-time constants because subsequent implementations of aplatform may upgrade locking operations with lock-free operations, soit is common for systems to abstract such facilities behind dynamiclibraries, and we wish to leave that possiblility open. Furthermore,we recommend that implementations without hardware atomic support usethat technique. …
並且(如Jesse Good 所指出):
The proposal provides lock-free query functions on individual objects rather than whole types to permit unavoidably misaligned atomic variables without penalizing the performance of aligned atomic variables
程式碼日誌版權宣告:
翻譯自:http://stackoverflow.com/questions/10407514/why-is-is-lock-free-a-member-function