本文整理汇总了C++中thread::joinable方法的典型用法代码示例。如果您正苦于以下问题:C++ thread::joinable方法的具体用法?C++ thread::joinable怎么用?C++ thread::joinable使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类thread
的用法示例。
在下文中一共展示了thread::joinable方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: return
JNIEXPORT jint JNICALL Java_org_iotivity_ResourceHosting_ResourceHosting_ResourceHostingTerminate
(JNIEnv *env, jobject obj)
{
if (OCStop() != OC_STACK_OK)
{
return (jint)OCSTACK_ERROR;
}
//terminate Thread
if (ocProcessThread.joinable())
{
threadRun = false;
ocProcessThread.join();
}
else
{
return (jint)HOSTING_THREAD_ERROR;
}
return (jint)OCSTACK_OK;
}
示例2: join
void join()
{
if (runner.joinable())
runner.join();
}
示例3:
~runandjoin() {
if (runner.joinable())
runner.join();
}
示例4: Menu_Clicked
void Menu_Clicked()
{
char picked[80];
menubar->item_pathname(picked, sizeof(picked)-1);
string selectPath(picked);
cout << "Selected Menu Path: " << selectPath << endl;
int selected = mediaType->value();
cout << "Selected media type: " << ((select == 0) ? "Music" : "Video") << endl;
if(selectPath.compare("File/Save") == 0)
{
cout << "Menu item Save selected." << endl;
}
else if(selectPath.compare("File/Restore") == 0)
{
cout << "Menu item Restore selected." << endl;
}
else if(selectPath.compare("File/Exit") == 0)
{
cout << "Menu item Exit selected." << endl;
if(playThread != NULL && playThread->joinable())
{
playThread->join();
}
exit(0);
}
else if(selectPath.compare("Media/Add") == 0)
{
cout << "Menu item Add selected." << endl;
cout << "Adding media with title: " << titleInput->value()
<< ", type " << mediaType->value() << " " << endl;
MediaDescription file(mediaType->value(), titleInput->value(),
authorInput->value(), albumInput->value(), genreInput->value(),
filenameInput->value());
bool addRes = false;
addRes = (*msc).add(file.toJSONObject());
cout << "Add " << ((addRes) ? "successful" : "unsuccessful") << endl;
}
else if(selectPath.compare("Media/Remove") == 0)
{
string title = titleInput->value();
bool remRes = false;
remRes = msc->remove(title);
cout << "Remove " << ((remRes) ? "successful" : "uneuccessful") << endl;
}
else if(selectPath.compare("File/Refresh Tree") == 0)
{
//rebuild tree here
buildTree();
}
else if(selectPath.compare("Media/Play") == 0)
{
string unameres = exec("uname");
string pwdPath = exec("pwd");
pwdPath = pwdPath.substr(0, pwdPath.length()-1);
cout << "OS type is: " << unameres << " curr.dir is: " << pwdPath
<< endl;
stringstream streamLinux;
streamLinux << "/usr/bin/vlc " << pwdPath << "/"
<< ((mediaType->value() == 0) ? "PaperNavySwanSong.mp3" :
"MachuPicchuTimeLapseVimeo.mp4");
string aStr("Linux");
cout << "Linux command: " << streamLinux.str() << endl;
string argLinux(streamLinux.str());
cmd = argLinux;
playThread = new thread(run);
}
}
示例5:
~TioTesterSubscriber()
{
assert(!thread_.joinable());
}
示例6: join
void join() {
if (t.joinable())
t.join();
}