Stroika Library 3.0d25
 
Loading...
Searching...
No Matches
TimedLock.h File Reference
#include "Stroika/Foundation/StroikaPreComp.h"
#include <chrono>
#include <mutex>
#include "Stroika/Foundation/Common/StdCompat.h"
#include "Stroika/Foundation/Execution/Timeout.h"
#include "Stroika/Foundation/Time/Realtime.h"
#include "TimedLock.inl"

Go to the source code of this file.

Namespaces

namespace  Stroika::Foundation
 
namespace  Stroika::Foundation::Execution
 

Functions

template<Common::StdCompat::TimedMutex TIMED_MUTEX, typename EXCEPTION >
void Stroika::Foundation::Execution::TryLockUntil (TIMED_MUTEX &m, Time::TimePointSeconds afterTickCount, EXCEPTION &&exception2Throw)
 
template<Common::StdCompat::TimedMutex TIMED_MUTEX, typename EXCEPTION >
unique_lock< TIMED_MUTEX > Stroika::Foundation::Execution::UniqueLock (TIMED_MUTEX &m, const chrono::duration< double > &d, EXCEPTION &&exception2Throw)
 

Detailed Description

Acquiring a lock with a DEADLINE, where failing to get it in time is an error rather than something the caller polls for. Both helpers here report that failure the one way Stroika reports any timeout -

See also
Execution/Timeout.h - so the caller writes straight-line code and handles the timeout with a catch rather than a branch.

For a lock with no deadline, just use std::lock_guard / std::unique_lock directly.

Definition in file TimedLock.h.