本文整理汇总了C++中boost::condition::notify_all方法的典型用法代码示例。如果您正苦于以下问题:C++ condition::notify_all方法的具体用法?C++ condition::notify_all怎么用?C++ condition::notify_all使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::condition
的用法示例。
在下文中一共展示了condition::notify_all方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: player
void player(int active)
{
boost::unique_lock<boost::mutex> lock(mutex);
int other = active == PLAYER_A ? PLAYER_B : PLAYER_A;
while (state < GAME_OVER)
{
//std::cout << player_name(active) << ": Play." << std::endl;
state = other;
cond.notify_all();
do
{
cond.wait(lock);
if (state == other)
{
std::cout << "---" << player_name(active)
<< ": Spurious wakeup!" << std::endl;
}
} while (state == other);
}
++state;
std::cout << player_name(active) << ": Gone." << std::endl;
cond.notify_all();
}
示例2: deactivate_
void deactivate_()
{
if ( active_)
{
active_ = false;
not_empty_cond_.notify_all();
not_full_cond_.notify_all();
}
}
示例3: lock
void
interpreter_lock_impl::unlock() {
boost::mutex::scoped_lock lock(mutex_);
assert(NULL != thread_state_);
/* thread_state_ = */ PyEval_SaveThread();
if (!--thread_lock_count_) {
condition_.notify_all();
}
}
示例4: SlotOnNewStateHandler
void SlotOnNewStateHandler(net::ClientId client_id, net::ServerId server_id, net::ClientState client_state)
{
if (client_state != net::CLIENT_STATE_CONNECTED)
{
std::cout << "Disconnected from server." << std::endl;
this->client_id_ = 0;
finish = true;
on_message_condition.notify_all();
}
}
示例5: release_read_lock
void release_read_lock()
{
boost::mutex::scoped_lock lock(mtx);
--num_readers;
if(num_readers == 0)
{
// must notify_all here, since if there are multiple waiting writers
// they should all be woken (they continue to acquire the lock
// exclusively though)
no_readers.notify_all();
}
}
示例6: main
int main()
{
state = START;
boost::thread thrda(&player, PLAYER_A);
boost::thread thrdb(&player, PLAYER_B);
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC_);
xt.sec += 1;
boost::thread::sleep(xt);
{
boost::unique_lock<boost::mutex> lock(mutex);
std::cout << "---Noise ON..." << std::endl;
}
for (int i = 0; i < 10; ++i)
cond.notify_all();
{
boost::unique_lock<boost::mutex> lock(mutex);
std::cout << "---Noise OFF..." << std::endl;
state = GAME_OVER;
cond.notify_all();
do
{
cond.wait(lock);
} while (state != BOTH_PLAYERS_GONE);
}
std::cout << "GAME OVER" << std::endl;
thrda.join();
thrdb.join();
return 0;
}
示例7: main
int main(int argc, char* argv[])
{
state = START;
boost::thread thrda(thread_adapter(&player, (void*)PLAYER_A));
boost::thread thrdb(thread_adapter(&player, (void*)PLAYER_B));
boost::xtime xt;
boost::xtime_get(&xt, boost::TIME_UTC);
xt.sec += 1;
boost::thread::sleep(xt);
{
boost::mutex::scoped_lock lock(mutex);
std::cout << "---Noise ON..." << std::endl;
}
for (int i = 0; i < 1000000; ++i)
cond.notify_all();
{
boost::mutex::scoped_lock lock(mutex);
std::cout << "---Noise OFF..." << std::endl;
state = GAME_OVER;
cond.notify_all();
do
{
cond.wait(lock);
} while (state != BOTH_PLAYERS_GONE);
}
std::cout << "GAME OVER" << std::endl;
thrda.join();
thrdb.join();
return 0;
}
示例8: console_ctrl_handler
BOOL WINAPI console_ctrl_handler(DWORD ctrl_type)
{
switch (ctrl_type)
{
case CTRL_C_EVENT:
case CTRL_BREAK_EVENT:
case CTRL_CLOSE_EVENT:
case CTRL_SHUTDOWN_EVENT:
{
boost::mutex::scoped_lock terminationLock(terminationMutex);
terminationRequested = true;
terminationCondition.notify_all(); // should be just 1
return TRUE;
}
default:
return FALSE;
}
}
示例9: release_write_lock
void release_write_lock()
{
boost::mutex::scoped_lock lock(mtx);
is_current_writer = false;
writer_finished.notify_all();
}
示例10: SlotOnNewDataHandler
void SlotOnNewDataHandler(net::ClientId client_id, net::ServerId server_id, common::Byteset data)
{
for (unsigned int n = 0; n < data.GetSize(); n++)
{
this->buffer_.push_back(data[n]);
}
while (this->buffer_.size() >= 8)
{
std::string command = "";
command += (char)this->buffer_[0];
command += (char)this->buffer_[1];
command += (char)this->buffer_[2];
command += (char)this->buffer_[3];
std::string payload_length_str = "";
payload_length_str += (char)this->buffer_[4];
payload_length_str += (char)this->buffer_[5];
payload_length_str += (char)this->buffer_[6];
payload_length_str += (char)this->buffer_[7];
unsigned int payload_length = boost::lexical_cast<unsigned int>(payload_length_str);
if (this->buffer_.size() - 8 < payload_length)
{
return;
}
std::string payload = "";
for (unsigned int n = 8; n < payload_length + 8; n++)
{
payload += (char)this->buffer_[n];
}
this->buffer_.erase(this->buffer_.begin(), this->buffer_.begin() + payload_length + 8);
if (command == "TEXT")
{
std::cout << payload << std::flush;
}
else if (command == "PROM")
{
this->prompt_ = payload;
on_message_condition.notify_all();
}
else if (command == "COMP")
{
autocomplete_list.clear();
if (payload.length() > 0)
{
boost::algorithm::split(autocomplete_list, payload, boost::is_any_of("\n"), boost::algorithm::token_compress_on);
}
on_message_condition.notify_all();
}
else
{
std::cerr << "Could not parse package." << std::endl;
finish = true;
on_message_condition.notify_all();
break;
}
}
}
示例11: terminate
void WServer::terminate()
{
boost::mutex::scoped_lock terminationLock(terminationMutex);
terminationRequested = true;
terminationCondition.notify_all(); // should be just 1
}
示例12:
inline void
boost_threaded_monitor::notify_all() {
cond_.notify_all();
}