本文整理汇总了C++中boost::thread::interrupt方法的典型用法代码示例。如果您正苦于以下问题:C++ thread::interrupt方法的具体用法?C++ thread::interrupt怎么用?C++ thread::interrupt使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::thread
的用法示例。
在下文中一共展示了thread::interrupt方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
virtual ~Log()
{
_isStopping = true;
_threadPool.interrupt_all();
_threadPool.join_all();
_stringLoggerThread.interrupt();
_stringLoggerThread.join();
}
示例2:
~Server()
{
acceptor.cancel();
data_worker.interrupt();
data_worker.join();
work = boost::none;
io_worker.join();
}
示例3: shutdown
virtual void shutdown(ExecutorDriver* driver) {
driver->sendFrameworkMessage("Executor " + host_name+ "SHUTTING DOWN");
if (thread) {
thread->interrupt();
thread->join();
delete thread;
thread = 0;
}
driver->stop();
}
示例4: killTask
virtual void killTask(ExecutorDriver* driver, const TaskID& taskId) {
if (thread) {
thread->interrupt();
thread->join();
delete thread;
thread = 0;
}
driver->sendFrameworkMessage("Executor " + host_name+ " KILLING TASK");
driver->stop();
}
示例5: Abort
int Worker::Abort()
{
// lock nothing coz care nothing ...
if(m_state <= 0) return m_state;
m_state = -1;
if(m_thread) m_thread->interrupt(); // force to get out
//usleep(50 * 1000);
return m_state;
}
示例6: fflush
inline threadTest::~threadTest()
{
_glInit = false;
_glThread.interrupt();
std::cout << "Interrupting main thread" << std::endl;
fflush(stdout);
_glThread.join();
std::cout << "Joinning main thread" << std::endl;
fflush(stdout);
printTest();
std::cout << "Main thread destroyed" << std::endl;
fflush(stdout);
};
示例7: catch
void nuke_ms::clientnode::catchThread(boost::thread& thread, unsigned threadwait_ms)
{
// a thread id that compares equal to "not-a-thread"
boost::thread::id not_a_thread;
try {
// give the thread a few seconds time to join
thread.timed_join(boost::posix_time::millisec(threadwait_ms));
}
catch(...)
{}
// if the thread finished, return. otherwise try to kill the thread
if (thread.get_id() == not_a_thread)
return;
thread.interrupt();
// if it is still running, let it go
if (thread.get_id() == not_a_thread)
return;
thread.detach();
}
示例8:
~timer_queue_t() {
watchdog.interrupt();
watchdog.join();
}
示例9: launchTask
//.........这里部分代码省略.........
YAML::Node curMaster = YAML::Load(YAML::Dump(peerParams["peers"][0]));
masters.push_back(YAML::Load(YAML::Dump(curMaster)));
std::cout << peerParams["peers"].size() << " peers to map" << endl;
for (std::size_t i=0; i< peerParams["peers"].size(); i++) {
YAML::Node kv;
if (peerParams["peers"][i]["addr"][0].as<string>() != curMaster["addr"][0].as<string>()) {
cout << "Host: " << curMaster["addr"][0].as<string>() << ". Peers: " << pph << endl;
pph = 0;
masters.push_back(YAML::Load(YAML::Dump(peerParams["peers"][i])));
curMaster = YAML::Load(YAML::Dump(peerParams["peers"][i]));
}
pph++;
std::cout << "added one" << endl;
kv["key"] = YAML::Load(YAML::Dump(peerParams["peers"][i]["addr"]));
kv["value"] = YAML::Load(YAML::Dump(curMaster["addr"]));
peer_masters.push_back(kv);
}
cout << "Host: " << curMaster["addr"][0].as<string>() << ". Peers: " << pph << endl;
peerParams["peer_masters"] = YAML::Load(YAML::Dump(peer_masters));
peerParams["masters"] = YAML::Load(YAML::Dump(masters));
std::cout << "Masters: " << YAML::Dump(masters) << endl;
}
std::ostringstream oss;
oss << "PEERS!!! (" << std::endl;
for (std::size_t i=0; i<peers.size(); i++) {
oss << "---" << std::endl;
YAML::Node thispeer = peerParams;
YAML::Node globals = hostParams["globals"][i];
for (const_iterator p=globals.begin(); p!=globals.end(); p++) {
thispeer[p->first.as<string>()] = p->second;
}
YAML::Node me = peers[i];
thispeer["me"] = me;
YAML::Node local_peers;
std::cout << "start: " << peerStart << ". end: " << peerEnd << std::endl;
for (int j=peerStart; j<= peerEnd; j++) {
local_peers.push_back(YAML::Load(YAML::Dump(peerParams["peers"][j])));
}
thispeer["local_peers"] = YAML::Load(YAML::Dump(local_peers));
for (auto it : peerFiles[i]) {
auto datavar = it.first;
if (thispeer[datavar]) {
thispeer.remove(datavar);
}
for (auto &f : it.second) {
Node src;
src["path"] = f;
thispeer[datavar].push_back(src);
}
}
// ADD DATA SOURCE DIR HERE
YAML::Emitter emit;
emit << YAML::Flow << thispeer;
string param = emit.c_str();
std::ofstream peerFile;
string peerFileName = "/mnt/mesos/sandbox/peers" + std::to_string(i) + ".yaml";
peerFile.open(peerFileName, std::ofstream::out);
peerFile << param;
peerFile.close();
oss << param << std::endl;
std::cout << param << std::endl;
k3_cmd += " -p " + peerFileName;
for (auto it : peerFiles[i]) {
auto datavar = it.first;
if (thispeer[datavar]) {
thispeer.remove(datavar);
}
}
}
oss << ") END PEERS!!!" << std::endl;
cout << oss.str() << std::endl;
k3_cmd += "'";
cout << "FINAL COMMAND: " << k3_cmd << endl;
if (thread) {
driver->sendFrameworkMessage("Debug: thread already existed!");
thread->interrupt();
thread->join();
delete thread;
thread = 0;
}
bool isMaster = false;
cout << "Checking master" << endl;
if (Dump(hostParams["me"][0]) == Dump(hostParams["master"])) {
isMaster = true;
cout << "I am master" << endl;
}
else {
cout << "me: " << Dump(hostParams["me"][0]) << endl;
cout << "master: " << Dump(hostParams["master"]) << endl;
}
cout << "Launching K3: " << endl;
thread = new boost::thread(TaskThread(task, k3_cmd, driver, isMaster));
}