oj mrJudge
Toggle navigation
  • Login
    • Forget Password
      Login
User Image

Hello, Stranger

Guest
  • Analysis Mode
  • Problems
    • All Problems
    • Latest Problems
  • Join Us Now
  • Registration
  • Contact Us
  • Infomation
  • C++ Reference
  • About
    • Help
    • Terms of Use
    • Technical Specifications
    • Credits

C++ Reference as of 28 May 2018

C++ concepts: SharedMutex - cppreference.com

C++ concepts: SharedMutex

From cppreference.com
< cpp‎ | concept
 
C++
Language
Headers
Library concepts
Language support library
Diagnostics library
Utilities library
Strings library
Containers library
Algorithms library
Iterators library
Numerics library
Input/output library
Localizations library
Regular expressions library (C++11)
Atomic operations library (C++11)
Thread support library (C++11)
Filesystem library (C++17)
Technical Specifications
 
C++ concepts
Basic
DefaultConstructible
CopyAssignable
CopyConstructible
MoveAssignable
(C++11)
MoveConstructible
(C++11)
Destructible
Layout
TrivialType
(C++11)
TriviallyCopyable
(C++11)
StandardLayoutType
(C++11)
PODType
Library-Wide
EqualityComparable
LessThanComparable
Swappable
(C++11)
ValueSwappable
(C++11)
NullablePointer
(C++11)
Hash
(C++11)
Allocator
FunctionObject
Callable
Predicate
BinaryPredicate
Compare
Container
Container
SequenceContainer
ContiguousContainer
(C++17)
ReversibleContainer
AssociativeContainer
AllocatorAwareContainer
UnorderedAssociativeContainer
(C++11)
Container Elements
DefaultInsertable
(C++11)
CopyInsertable
(C++11)
MoveInsertable
(C++11)
EmplaceConstructible
(C++11)
Erasable
(C++11)
Iterator
Iterator
OutputIterator
InputIterator
ForwardIterator
BidirectionalIterator
RandomAccessIterator
ContiguousIterator
(C++17)
Stream I/O
FormattedInputFunction
UnformattedInputFunction
FormattedOutputFunction
UnformattedOutputFunction
Random Numbers
SeedSequence
(C++11)
RandomNumberEngine
(C++11)
RandomNumberDistribution
(C++11)
UniformRandomBitGenerator
(C++11)
RandomNumberEngineAdaptor
(C++11)
Concurrency
BasicLockable
(C++11)
Lockable
(C++11)
TimedLockable
(C++11)
Mutex
(C++11)
TimedMutex
(C++11)
SharedMutex
(C++17)
SharedTimedMutex
(C++14)
Other
CharTraits
RegexTraits
(C++11)
BitmaskType
NumericType
LiteralType
(C++11)
UnaryTypeTrait
(C++11)
BinaryTypeTrait
(C++11)
TransformationTrait
(C++11)
Clock
(C++11)
TrivialClock
(C++11)
 

The SharedMutex concept extends the Mutex concept to include shared lock ownership mode.

Requirements

  • Mutex

Additionally, for object m of SharedMutex type supports another mode of ownership: shared. Multiple threads (or, more generally, execution agents) can simultaneously own this mutex in shared mode, but no thread may obtain shared ownership if there is a thread that owns it in exclusive mode and no thread may obtain exclusive ownership if there is a thread that owns it in shared mode. If more than implementation-defined number of threads (no less than 10000) hold a shared lock, another attempt to acquire the mutex in shared mode blocks until the number of shared owners drops down below that threshold.

  • The expression m.lock_shared() has the following properties
  • Behaves as an atomic operation.
  • Blocks the calling thread until shared ownership of the mutex can be obtained.
  • Prior m.unlock() operations on the same mutex synchronize-with this lock operation (equivalent to release-acquire std::memory_order)
  • The behavior is undefined if the calling thread already owns the mutex in any mode.
  • If an exception is thrown, the shared lock is not acquired.
  • The expression m.try_lock_shared() has the following properties
  • Behaves as an atomic operation.
  • Attempts to obtain shared ownership of the mutex for the calling thread without blocking. If ownership is not obtained, returns immediately. The function is allowed to spuriously fail and return even if the mutex is not currently owned by any threads in any mode.
  • If try_lock_shared() succeeds, prior unlock() operations on the same object synchronize-with this operation (equivalent to release-acquire std::memory_order).
  • The behavior is undefined if the calling thread already owns the mutex in any mode
  • The expression m.unlock_shared() has the following properties
  • Behaves as an atomic operation.
  • Releases the calling thread's ownership of the mutex and synchronizes-with the subsequent successful lock operations on the same object.
  • The behavior is undefined if the calling thread does not own the mutex.
  • All lock and unlock operations on a single mutex occur in a single total order

Library types

The following standard library types satisfy SharedMutex:

  • std::shared_mutex(since C++17)
  • std::shared_timed_mutex(since C++14)

See also

  • Thread support library
  • Mutex
  • TimedMutex
  • SharedTimedMutex
Retrieved from "http://en.cppreference.com/mwiki/index.php?title=cpp/concept/SharedMutex&oldid=98958"
Navigation
  • Online version
  • Offline version retrieved 2018-04-14 22:05.
  • This page was last modified on 6 February 2018, at 09:04.
  • This page has been accessed 12,077 times.
mrJudge 31.05.2018 (F43DD)
Copyright © 2018 mrJudge. All rights reserved.

Under Construction

Stats Tab Content

Under Construction too