3 #ifndef INCLUDE_NN_NLIB_THREADING_SHAREDCRITICALSECTION_H_
4 #define INCLUDE_NN_NLIB_THREADING_SHAREDCRITICALSECTION_H_
14 #ifdef NLIB_CXX11_CONSTEXPR
37 NLIB_ASSERT(e == 0 || e == EBUSY);
41 NLIB_SHARED_TRYLOCK_FUNC(
true) {
43 NLIB_ASSERT(e == 0 || e == ETIMEDOUT);
47 NLIB_SHARED_TRYLOCK_FUNC(
true) {
49 NLIB_ASSERT(e == 0 || e == ETIMEDOUT);
65 NLIB_ASSERT(e == 0 || e == EBUSY);
70 NLIB_ASSERT(e == 0 || e == ETIMEDOUT);
75 NLIB_ASSERT(e == 0 || e == ETIMEDOUT);
91 #ifdef NLIB_CXX11_CONSTEXPR
93 : condrwlock_(NLIB_CONDRWLOCK_INITIALIZER) {}
103 NLIB_ASSERT_NOERR(e);
109 NLIB_ASSERT_NOERR(e);
114 NLIB_ASSERT_NOERR(e);
132 timeout.ToTimeValue().tick, 1);
136 timeout.ToTimeValue().tick, 1);
140 timeout.ToTimeValue().tick, 0);
144 timeout.ToTimeValue().tick, 0);
149 datetime.ToTimeValue().tick, 1);
153 datetime.ToTimeValue().tick, 1);
157 datetime.ToTimeValue().tick, 0);
161 datetime.ToTimeValue().tick, 0);
172 #endif // INCLUDE_NN_NLIB_THREADING_SHAREDCRITICALSECTION_H_
A conditional variable for SharedCriticalSection and nlib_rwlock. This variable can be used in the sa...
#define NLIB_NOEXCEPT
Defines noexcept geared to the environment, or the equivalent.
errno_t WaitFor(nlib_rwlock &lock, const TimeSpan &timeout) noexcept
Unlocks a write lock and waits for a conditional variable signal for a specified period. Also see nlib_condrwlock_wait_for().
#define NLIB_FINAL
Defines final if it is available for use. If not, holds an empty string.
constexpr CondVarForSharedCriticalSection() noexcept
Instantiates the object with default parameters (default constructor).
~CondVarForSharedCriticalSection() noexcept
Destructor.
void Notify() noexcept
Signals to at least one waiting thread. Also see nlib_condrwlock_signal().
void unlock_shared() noexcept NLIB_SHARED_UNLOCK_FUNC()
Releases the read lock.
errno_t WaitReader(SharedCriticalSection &lock) noexcept
Unlocks a read lock and waits for a conditional variable signal. Also see nlib_condrwlock_wait().
errno_t WaitUntil(SharedCriticalSection &lock, const DateTime &datetime) noexcept
Unlocks a write lock and waits for a conditional variable signal until specified date and time...
errno_t WaitReaderFor(nlib_rwlock &lock, const TimeSpan &timeout) noexcept
Unlocks a read lock and waits for a conditional variable signal for a specified period. Also see nlib_condrwlock_wait_for().
The class for representing the date and time.
errno_t WaitReaderFor(SharedCriticalSection &lock, const TimeSpan &timeout) noexcept
Unlocks a read lock and waits for a conditional variable signal for a specified period. Also see nlib_condrwlock_wait_for().
Implements a read/write lock. Used when multiple threads simultaneously read data, and a single thread writes data.
errno_t WaitReader(nlib_rwlock &lock) noexcept
Unlocks a read lock and waits for a conditional variable signal. Also see nlib_condrwlock_wait().
bool try_lock_shared_until(const DateTime &abstime) noexcept NLIB_SHARED_TRYLOCK_FUNC(true)
Gets the read lock, and attempts to enter the critical section. Times out.
void lock() noexcept NLIB_LOCK_FUNC()
Gets a write lock, and enters the critical section. Blocks until it can get a lock.
errno_t Wait(SharedCriticalSection &lock) noexcept
Unlocks a write lock and waits for a conditional variable signal. Also see nlib_condrwlock_wait().
errno_t WaitReaderUntil(nlib_rwlock &lock, const DateTime &datetime) noexcept
Unlocks a read lock and waits for a conditional variable signal until specified date and time...
Defines the class for handling times and durations.
errno_t Wait(nlib_rwlock &lock) noexcept
Unlocks a write lock and waits for a conditional variable signal. Also see nlib_condrwlock_wait().
A file that contains the configuration information for each development environment.
void lock_shared() noexcept NLIB_SHARED_LOCK_FUNC()
Gets the read lock, and enters the critical section. Blocks until it can get a lock.
bool try_lock_until(const DateTime &abstime) noexcept NLIB_TRYLOCK_FUNC(true)
Gets a write lock, and attempts to enter the critical section. Times out.
errno_t WaitUntil(nlib_rwlock &lock, const DateTime &datetime) noexcept
Unlocks a write lock and waits for a conditional variable signal until specified date and time...
bool try_lock_for(const TimeSpan &timeout) noexcept NLIB_TRYLOCK_FUNC(true)
Gets a write lock, and attempts to enter the critical section. Times out.
void unlock() noexcept NLIB_UNLOCK_FUNC()
Releases a write lock.
bool try_lock_shared() noexcept NLIB_SHARED_TRYLOCK_FUNC(true)
Gets the read lock, and attempts to enter the critical section.
The class for representing the time.
constexpr SharedCriticalSection() noexcept
Instantiates the object with default parameters (default constructor).
errno_t WaitFor(SharedCriticalSection &lock, const TimeSpan &timeout) noexcept
Unlocks a write lock and waits for a conditional variable signal for a specified period. Also see nlib_condrwlock_wait_for().
errno_t WaitReaderUntil(SharedCriticalSection &lock, const DateTime &datetime) noexcept
Unlocks a read lock and waits for a conditional variable signal until specified date and time...
bool try_lock_shared_for(const TimeSpan &timeout) noexcept NLIB_SHARED_TRYLOCK_FUNC(true)
Gets the read lock, and attempts to enter the critical section. Times out.
void NotifyAll() noexcept
Signals all waiting threads. Also see nlib_condrwlock_broadcast().
bool try_lock() noexcept NLIB_TRYLOCK_FUNC(true)
Gets a write lock, and attempts to enter the critical section.