bool waitForAnomalyCount( int i ) { while( 1 ) { auto timeout = chrono::system_clock::now() + chrono::milliseconds( 300000 ); unique_lock<mutex> lock( clock ); if( anomaliesTriggered >= i ) { return true; } if( cond.wait_until( lock, timeout ) == cv_status::timeout ) { return false; } } }
channel_op_status pop_wait_until( value_type & va, std::chrono::time_point< Clock, Duration > const& timeout_time) { std::unique_lock< mutex > lk( mtx_); if ( ! not_empty_cond_.wait_until( lk, timeout_time, [this](){ return is_closed_() || ! is_empty_(); })) { return channel_op_status::timeout; } if ( is_closed_() && is_empty_() ) { return channel_op_status::closed; } va = value_pop_( lk); return channel_op_status::success; }