| 
    PMDK C++ bindings
    1.7
    
   This is the C++ bindings documentation for PMDK's libpmemobj. 
   | 
 
 
 
 
Go to the documentation of this file.
   38 #ifndef LIBPMEMOBJ_CPP_CONDVARIABLE_HPP 
   39 #define LIBPMEMOBJ_CPP_CONDVARIABLE_HPP 
   42 #include <condition_variable> 
   46 #include <libpmemobj/thread.h> 
   63     typedef std::chrono::system_clock clock_type;
 
   78         if ((pop = pmemobj_pool_by_ptr(&
pcond)) == 
nullptr)
 
   80                 1, std::generic_category(),
 
   81                 "Persistent condition variable not from persistent memory.");
 
   83         pmemobj_cond_zero(pop, &
pcond);
 
  102         PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
 
  103         if (
int ret = pmemobj_cond_signal(pop, &this->
pcond))
 
  105                 ret, std::system_category(),
 
  106                 "Error notifying one on a condition variable.");
 
  117         PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
 
  118         if (
int ret = pmemobj_cond_broadcast(pop, &this->
pcond))
 
  120                 ret, std::system_category(),
 
  121                 "Error notifying all on a condition variable.");
 
  162     template <
typename Lock>
 
  188     template <
typename Predicate>
 
  216     template <
typename Lock, 
typename Predicate>
 
  218     wait(Lock &lock, Predicate pred)
 
  220         this->
wait_impl(*lock.mutex(), std::move(pred));
 
  244     template <
typename Clock, 
typename Duration>
 
  247            const std::chrono::time_point<Clock, Duration> &timeout)
 
  275     template <
typename Lock, 
typename Clock, 
typename Duration>
 
  278            const std::chrono::time_point<Clock, Duration> &timeout)
 
  305     template <
typename Clock, 
typename Duration, 
typename Predicate>
 
  308            const std::chrono::time_point<Clock, Duration> &timeout,
 
  338     template <
typename Lock, 
typename Clock, 
typename Duration,
 
  342            const std::chrono::time_point<Clock, Duration> &timeout,
 
  372     template <
typename Lock, 
typename Rep, 
typename Period>
 
  374     wait_for(Lock &lock, 
const std::chrono::duration<Rep, Period> &rel_time)
 
  377                          clock_type::now() + rel_time);
 
  404     template <
typename Lock, 
typename Rep, 
typename Period,
 
  407     wait_for(Lock &lock, 
const std::chrono::duration<Rep, Period> &rel_time,
 
  411                          clock_type::now() + rel_time,
 
  436     template <
typename Rep, 
typename Period>
 
  439          const std::chrono::duration<Rep, Period> &rel_time)
 
  442                          clock_type::now() + rel_time);
 
  467     template <
typename Rep, 
typename Period, 
typename Predicate>
 
  470          const std::chrono::duration<Rep, Period> &rel_time,
 
  505         PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
 
  506         if (
int ret = pmemobj_cond_wait(pop, &this->
pcond,
 
  509                 ret, std::system_category(),
 
  510                 "Error waiting on a condition variable.");
 
  516     template <
typename Predicate>
 
  527     template <
typename Clock, 
typename Duration>
 
  531         const std::chrono::time_point<Clock, Duration> &abs_timeout)
 
  533         PMEMobjpool *pop = pmemobj_pool_by_ptr(
this);
 
  536         const typename Clock::time_point their_now = Clock::now();
 
  537         const clock_type::time_point my_now = clock_type::now();
 
  538         const auto delta = abs_timeout - their_now;
 
  539         const auto my_rel = my_now + delta;
 
  541         struct timespec ts = detail::timepoint_to_timespec(my_rel);
 
  543         auto ret = pmemobj_cond_timedwait(pop, &this->
pcond,
 
  547             return std::cv_status::no_timeout;
 
  548         else if (ret == ETIMEDOUT)
 
  549             return std::cv_status::timeout;
 
  552                 ret, std::system_category(),
 
  553                 "Error waiting on a condition variable.");
 
  559     template <
typename Clock, 
typename Duration, 
typename Predicate>
 
  563         const std::chrono::time_point<Clock, Duration> &abs_timeout,
 
  568                 std::cv_status::timeout)
 
  
std::cv_status wait_until(mutex &lock, const std::chrono::time_point< Clock, Duration > &timeout)
Makes the current thread block until the condition variable is notified, a specific time is reached o...
Definition: condition_variable.hpp:246
 
std::cv_status wait_for(mutex &lock, const std::chrono::duration< Rep, Period > &rel_time)
Makes the current thread block until the condition variable is notified, the specified amount of time...
Definition: condition_variable.hpp:438
 
std::cv_status wait_for(Lock &lock, const std::chrono::duration< Rep, Period > &rel_time)
Makes the current thread block until the condition variable is notified, the specified amount of time...
Definition: condition_variable.hpp:374
 
Persistent memory resident mutex implementation.
Definition: mutex.hpp:60
 
bool wait_for(mutex &lock, const std::chrono::duration< Rep, Period > &rel_time, Predicate pred)
Makes the current thread block until the condition variable is notified or the specified amount of ti...
Definition: condition_variable.hpp:469
 
PMEMcond pcond
A POSIX style PMEM-resident condition variable.
Definition: condition_variable.hpp:574
 
native_handle_type native_handle() noexcept
Access a native handle to this condition variable.
Definition: mutex.hpp:158
 
Commonly used conversions.
 
condition_variable()
Default constructor.
Definition: condition_variable.hpp:75
 
std::cv_status wait_until_impl(mutex &lock, const std::chrono::time_point< Clock, Duration > &abs_timeout)
Internal implementation of the wait_until call.
Definition: condition_variable.hpp:529
 
void wait(mutex &lock)
Makes the current thread block until the condition variable is notified or it is woken up by some oth...
Definition: condition_variable.hpp:140
 
void notify_one()
Notify and unblock one thread waiting on *this condition.
Definition: condition_variable.hpp:100
 
condition_variable & operator=(const condition_variable &)=delete
Deleted assignment operator.
 
void wait(mutex &lock, Predicate pred)
Makes the current thread block until the condition variable is notified.
Definition: condition_variable.hpp:190
 
void wait_impl(mutex &lock, Predicate pred)
Internal implementation of the wait call.
Definition: condition_variable.hpp:518
 
Custom lock error class.
Definition: pexceptions.hpp:74
 
void wait(Lock &lock, Predicate pred)
Makes the current thread block until the condition variable is notified.
Definition: condition_variable.hpp:218
 
std::cv_status wait_until(Lock &lock, const std::chrono::time_point< Clock, Duration > &timeout)
Makes the current thread block until the condition variable is notified, a specific time is reached o...
Definition: condition_variable.hpp:277
 
native_handle_type native_handle() noexcept
Access a native handle to this condition variable.
Definition: condition_variable.hpp:483
 
condition_variable(const condition_variable &)=delete
Deleted copy constructor.
 
PMEMcond * native_handle_type
The handle typedef to the underlying basic type.
Definition: condition_variable.hpp:67
 
void wait_impl(mutex &lock)
Internal implementation of the wait call.
Definition: condition_variable.hpp:503
 
Persistent memory resident condition variable.
Definition: condition_variable.hpp:62
 
~condition_variable()=default
Defaulted destructor.
 
bool wait_until_impl(mutex &lock, const std::chrono::time_point< Clock, Duration > &abs_timeout, Predicate pred)
Internal implementation of the wait_until call.
Definition: condition_variable.hpp:561
 
void notify_all()
Notify and unblock all threads waiting on *this condition.
Definition: condition_variable.hpp:115
 
bool wait_until(mutex &lock, const std::chrono::time_point< Clock, Duration > &timeout, Predicate pred)
Makes the current thread block until the condition variable is notified or a specific time is reached...
Definition: condition_variable.hpp:307
 
bool wait_for(Lock &lock, const std::chrono::duration< Rep, Period > &rel_time, Predicate pred)
Makes the current thread block until the condition variable is notified or the specified amount of ti...
Definition: condition_variable.hpp:407
 
bool wait_until(Lock &lock, const std::chrono::time_point< Clock, Duration > &timeout, Predicate pred)
Makes the current thread block until the condition variable is notified or a specific time is reached...
Definition: condition_variable.hpp:341
 
void wait(Lock &lock)
Makes the current thread block until the condition variable is notified or it is woken up by some oth...
Definition: condition_variable.hpp:164