本文整理汇总了C++中boost::condition_variable::notify_one方法的典型用法代码示例。如果您正苦于以下问题:C++ condition_variable::notify_one方法的具体用法?C++ condition_variable::notify_one怎么用?C++ condition_variable::notify_one使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::condition_variable
的用法示例。
在下文中一共展示了condition_variable::notify_one方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: locking_thread
void locking_thread()
{
Lock lock(m);
boost::lock_guard<boost::mutex> lk(done_mutex);
locked=lock.owns_lock();
done=true;
done_cond.notify_one();
}
示例2: locking_thread
void locking_thread()
{
Lock lock(m,boost::defer_lock);
lock.timed_lock(boost::posix_time::milliseconds(50));
boost::lock_guard<boost::mutex> lk(done_mutex);
locked=lock.owns_lock();
done=true;
done_cond.notify_one();
}
示例3: enqueue
// Add data to the queue and notify others
void enqueue (const T& data)
{
// Acquire lock on the queue
boost::unique_lock<boost::mutex> lock (m_mutex);
// Add the data to the queue
m_queue.push (data);
// Notify others that data is ready
m_cond.notify_one();
}
示例4: colorImageCallback
/// Callback is executed, when shared mode is selected
/// Left and right is expressed when facing the back of the camera in horizontal orientation.
void colorImageCallback(const sensor_msgs::ImageConstPtr& color_camera_data,
const sensor_msgs::CameraInfoConstPtr& color_camera_info)
{
{
boost::mutex::scoped_lock lock( mutexQ_ );
ROS_DEBUG("[fiducials] color image callback");
if (camera_matrix_initialized_ == false)
{
camera_matrix_ = cv::Mat::zeros(3,3,CV_64FC1);
camera_matrix_.at<double>(0,0) = color_camera_info->K[0];
camera_matrix_.at<double>(0,2) = color_camera_info->K[2];
camera_matrix_.at<double>(1,1) = color_camera_info->K[4];
camera_matrix_.at<double>(1,2) = color_camera_info->K[5];
camera_matrix_.at<double>(2,2) = 1;
ROS_INFO("[fiducials] Initializing fiducial detector with camera matrix");
if (m_pi_tag->Init(camera_matrix_, model_directory_ + model_filename_) & ipa_Utils::RET_FAILED)
{
ROS_ERROR("[fiducials] Initializing fiducial detector with camera matrix [FAILED]");
return;
}
camera_matrix_initialized_ = true;
}
// Receive
color_image_8U3_ = cv_bridge_0_.imgMsgToCv(color_camera_data, "bgr8");
received_timestamp_ = color_camera_data->header.stamp;
received_frame_id_ = color_camera_data->header.frame_id;
cv::Mat tmp = color_image_8U3_;
color_mat_8U3_ = tmp.clone();
if (ros_node_mode_ == MODE_TOPIC || ros_node_mode_ == MODE_TOPIC_AND_SERVICE)
{
cob_object_detection_msgs::DetectionArray detection_array;
detectFiducials(detection_array, color_mat_8U3_);
// Publish
detect_fiducials_pub_.publish(detection_array);
cv_bridge::CvImage cv_ptr;
cv_ptr.image = color_mat_8U3_;
cv_ptr.encoding = CobFiducialsNode::color_image_encoding_;
img2D_pub_.publish(cv_ptr.toImageMsg());
}
synchronizer_received_ = true;
// Notify waiting thread
}
condQ_.notify_one();
}
示例5: Enqueue
// Add data to the queue and notify others
void Enqueue(const T& data) {
// Acquire lock on the queue
boost::unique_lock<boost::mutex> lock(m_mutex);
// Add the data to the queue
m_queue.push(data);
// Notify others that data is ready
m_cond.notify_one();
} // Lock is automatically released here
示例6: newBlock
virtual void newBlock(uint64_t height)
{
// std::cout << "wallet: " << wallet->mainAddress()
// <<", new block received, blockHeight: " << height << std::endl;
static int bc_height = wallet->daemonBlockChainHeight();
std::cout << height
<< " / " << bc_height/* 0*/
<< std::endl;
newblock_triggered = true;
cv_newblock.notify_one();
}
示例7: StopHardware
bool CGpio::StopHardware()
{
if (m_thread != NULL) {
m_stoprequested=true;
interruptCondition.notify_one();
m_thread->join();
}
m_bIsStarted=false;
return true;
}
示例8: RunConsumer
void A::RunConsumer() {
while (true) {
boost::mutex::scoped_lock lock(mutex_);
pushed_.wait(lock, [this]{return queue_.size()>MIN_QUEUE_WORK;});
Record res = queue_.front();
std::cout << "Processed: " << res.response << std::endl;
queue_.pop_front();
popped_.notify_one();
}
}
示例9: usr_signal
void usr_signal(int SigNo)
{
if (SigNo == SIGINT)
{
g_conditionMainRun.notify_one();
}
#ifndef WIN32
if (SigNo == SIGHUP)
{
}
#endif
}
示例10: push
void push(T const& data)
{
boost::mutex::scoped_lock lock(_mutex);
while(_queue.size() >= size)
{
_conditionVar.wait(lock);
}
_queue.push(data);
lock.unlock();
_conditionVar.notify_one();
}
示例11: push
void push(const TaskPtr& task) {
if (!_running) {
return;
}
boost::unique_lock<boost::mutex> lock(_mutex);
std::cout << "push A" << std::endl;
_tasks.push_back(task);
if (_tasks.size() >= 1) {
std::cout << "push B" << std::endl;
_no_task.notify_one();
std::cout << "push C" << std::endl;
}
}
示例12: do_work
/*
The actual work
*/
virtual int do_work()
{
for ( Iterator it = start ; it != end ; ++it )
{
privateSum += abs(abs(*it) + sin((unsigned long long)(*it)) * abs(cos(*it))) + ((float)*it * (unsigned short)*it) ;
}
boost::mutex::scoped_lock lock(m_mutex);
total_result += privateSum;
returned ++;
lock.unlock();
cv.notify_one();
return 0;
}
示例13: RunProducer
void A::RunProducer() {
int i = 0;
while (i<1000) {
boost::mutex::scoped_lock lock(mutex_);
popped_.wait(lock, [this] { return queue_.size()<MAX_QUEUE_WORK; });
queue_.push_back(Record { std::to_string(i).c_str() });
std::cout << "Added: " << std::to_string(i) << " size: " << queue_.size() << std::endl;
i++;
pushed_.notify_one();
}
}
示例14: commitIfNeeded
bool DurableImpl::commitIfNeeded(OperationContext* txn) {
// this is safe since since conceptually if you call commitIfNeeded, we're at a valid
// spot in an operation to be terminated.
cc().checkpointHappened();
if (MONGO_likely(commitJob.bytes() < UncommittedBytesLimit)) {
return false;
}
// Just wake up the flush thread
flushRequested.notify_one();
return true;
}
示例15: UpdateInvoker
//Must be called from secondary thread context
void Invoker::UpdateInvoker()
{
APP_API_ASSERT(m_Created);
boost::mutex::scoped_try_lock lock(*m_Mutex);
while(!m_Funcs.empty())
{
m_Funcs.front()();
CondVar.notify_one();
m_Funcs.pop();
}
}