Turi Create  4.0
turi::conditional Class Reference

#include <core/parallel/pthread_tools.hpp>

Public Member Functions

 conditional (const conditional &)
 
void wait (const mutex &mut) const
 
void wait (std::unique_lock< mutex > &mut) const
 
template<typename Predicate >
void wait (const mutex &mut, Predicate pred) const
 
template<typename Predicate >
void wait (std::unique_lock< mutex > &mut, Predicate pred) const
 
int timedwait (const mutex &mut, const struct timespec &timeout) const
 Wait till a timeout time.
 
int timedwait (const mutex &mut, size_t sec) const
 Like wait() but with a time limit of "sec" seconds.
 
int timedwait_ms (const mutex &mut, size_t ms) const
 Like wait() but with a time limit of "ms" milliseconds.
 
int timedwait_ns (const mutex &mut, size_t ns) const
 Like wait() but with a time limit of "ns" nanoseconds.
 
int timedwait (std::unique_lock< mutex > &mut, size_t sec) const
 Like wait() but with a time limit of "sec" seconds.
 
int timedwait_ms (std::unique_lock< mutex > &mut, size_t ms) const
 Like wait() but with a time limit of "ms" milliseconds.
 
int timedwait_ns (std::unique_lock< mutex > &mut, size_t ns) const
 Like wait() but with a time limit of "ns" nanoseconds.
 
void signal () const
 Signals one waiting thread to wake up.
 
void notify_one () const
 Signals one waiting thread to wake up. Synonym for signal()
 
void broadcast () const
 Wakes up all waiting threads.
 
void notify_all () const
 Synonym for broadcast.
 

Detailed Description

Wrapper around pthread's condition variable

Before you use, see parallel_object_intricacies.

Definition at line 205 of file pthread_tools.hpp.

Constructor & Destructor Documentation

◆ conditional()

turi::conditional::conditional ( const conditional )
inline

Copy constructor which does not copy. Do not use! Required for compatibility with some STL implementations (LLVM). which use the copy constructor for vector resize, rather than the standard constructor.

Definition at line 219 of file pthread_tools.hpp.

Member Function Documentation

◆ wait() [1/4]

void turi::conditional::wait ( const mutex mut) const
inline

Waits on condition. The mutex must already be acquired. Caller must be careful about spurious wakes.

Definition at line 230 of file pthread_tools.hpp.

◆ wait() [2/4]

void turi::conditional::wait ( std::unique_lock< mutex > &  mut) const
inline

Waits on condition. The mutex must already be acquired. Caller must be careful about spurious wakes.

Definition at line 242 of file pthread_tools.hpp.

◆ wait() [3/4]

template<typename Predicate >
void turi::conditional::wait ( const mutex mut,
Predicate  pred 
) const
inline

Waits on condition. The mutex must already be acquired. Returns only when predicate evaulates to true

Definition at line 255 of file pthread_tools.hpp.

◆ wait() [4/4]

template<typename Predicate >
void turi::conditional::wait ( std::unique_lock< mutex > &  mut,
Predicate  pred 
) const
inline

Waits on condition. The mutex must already be acquired. Returns only when predicate evaulates to true

Definition at line 261 of file pthread_tools.hpp.


The documentation for this class was generated from the following file: