本文整理汇总了C++中boost::thread::join方法的典型用法代码示例。如果您正苦于以下问题:C++ thread::join方法的具体用法?C++ thread::join怎么用?C++ thread::join使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::thread
的用法示例。
在下文中一共展示了thread::join方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1:
// Destructor : stop the brackground thread first !
inline ~pyPTAM() {
if (is_slam_started) {
s->Stop();
is_slam_started = false;
}
sys_thread->join();
}
示例2:
virtual ~Log()
{
_isStopping = true;
_threadPool.interrupt_all();
_threadPool.join_all();
_stringLoggerThread.interrupt();
_stringLoggerThread.join();
}
示例3: OpenDevice
//! デバイスを開く
//! 開くデバイスの指定は、現在WAVE_MAPPER固定。
//! 簡単のため例外安全性などはあまり考慮されていない点に注意。
bool OpenDevice(size_t sampling_rate, size_t channel, size_t block_size, size_t multiplicity, callback_function_t callback)
{
BOOST_ASSERT(0 < block_size);
BOOST_ASSERT(0 < multiplicity);
BOOST_ASSERT(0 < channel && channel <= 2);
BOOST_ASSERT(callback);
BOOST_ASSERT(!process_thread_.joinable());
block_size_ = block_size;
channel_ = channel;
callback_ = callback;
multiplicity_ = multiplicity;
//! デバイスがオープン完了するまでcallbackが呼ばれないようにするためのロック
boost::unique_lock<boost::mutex> lock(initial_lock_mutex_);
terminated_ = false;
process_thread_ = boost::thread([this] { ProcessThread(); });
WAVEFORMATEX wf;
wf.wFormatTag = WAVE_FORMAT_PCM;
wf.nChannels = 2;
wf.wBitsPerSample = 16;
wf.nBlockAlign = wf.nChannels * (wf.wBitsPerSample / 8);
wf.nSamplesPerSec = sampling_rate;
wf.nAvgBytesPerSec = wf.nBlockAlign * wf.nSamplesPerSec;
wf.cbSize = sizeof(WAVEFORMATEX);
headers_.resize(multiplicity_);
for(auto &header: headers_) {
header.reset(new WaveHeader(block_size * channel * sizeof(short)));
}
//! WAVEHDR使用済み通知を受け取る方式として
//! CALLBACK_FUNCTIONを指定。
//! 正常にデバイスがオープンできると、
//! waveOutWriteを呼び出した後でWaveOutProcessor::waveOutProcに通知が来るようになる。
MMRESULT const result =
waveOutOpen(
&hwo_,
0,
&wf,
reinterpret_cast<DWORD>(&WaveOutProcessor::waveOutProc),
reinterpret_cast<DWORD_PTR>(this),
CALLBACK_FUNCTION
);
if(result != MMSYSERR_NOERROR) {
terminated_ = true;
process_thread_.join();
terminated_ = false;
hwo_ = NULL;
return false;
}
return true;
}
示例4: 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();
}
示例5: 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();
}
示例6: Uninitialize
/**
* Disables the timer sub-system.
*/
void Timer::Uninitialize(void)
{
{
boost::mutex::scoped_lock lock(l_Mutex);
l_StopThread = true;
l_CV.notify_all();
}
l_Thread.join();
}
示例7:
~AsyncCRC32()
{
mutex.lock();
finished = true;
mutex.unlock();
readCond.notify_one();
thread.join();
for (auto buf : queue) delete buf;
}
示例8: Uninitialize
/**
* Disables the timer sub-system.
*/
void Timer::Uninitialize(void)
{
{
boost::mutex::scoped_lock lock(l_TimerMutex);
l_StopTimerThread = true;
l_TimerCV.notify_all();
}
if (l_TimerThread.joinable())
l_TimerThread.join();
}
示例9: fini
void LoopbackControllerManager::fini()
{
ROS_DEBUG("calling LoopbackControllerManager::fini");
//pr2_hardware_interface::ActuatorMap::const_iterator it;
//for (it = hw_.actuators_.begin(); it != hw_.actuators_.end(); ++it)
// delete it->second; // why is this causing double free corrpution?
cm_->~ControllerManager();
rosnode_->shutdown();
ros_spinner_thread_->join();
}
示例10: shutdown
void shutdown()
{
boost::recursive_mutex::scoped_lock lock(g_shutting_down_mutex);
// gracefully return if we've not fired ros up yet, or mid-shutdown
if (g_shutting_down || !g_initialized)
{
return;
}
ROSCPP_LOG_DEBUG("Shutting down roscpp");
g_shutting_down = true;
g_global_queue->disable();
g_global_queue->clear();
if (g_internal_queue_thread.get_id() != boost::this_thread::get_id())
{
g_internal_queue_thread.join();
}
const log4cxx::LoggerPtr& logger = log4cxx::Logger::getLogger(ROSCONSOLE_ROOT_LOGGER_NAME);
logger->removeAppender(g_rosout_appender);
g_rosout_appender = 0;
// reset this so that the logger doesn't get crashily destroyed
// again during global destruction.
//
// See https://code.ros.org/trac/ros/ticket/3271
//
log4cxx::Logger::getRootLogger()->getLoggerRepository()->shutdown();
log4cxx::LoggerPtr& fo_logger = ros::file_log::getFileOnlyLogger();
fo_logger = log4cxx::LoggerPtr();
if (g_started)
{
TopicManager::instance()->shutdown();
ServiceManager::instance()->shutdown();
PollManager::instance()->shutdown();
ConnectionManager::instance()->shutdown();
XMLRPCManager::instance()->shutdown();
}
WallTime end = WallTime::now();
ROSCPP_LOG_DEBUG("Shutdown finished");
g_started = false;
g_ok = false;
Time::shutdown();
}
示例11: Stop
int Worker::Stop()
{
// lock nothing coz care nothing ...
if(m_state <= 0) return m_state;
m_state = 0;
m_condition.notify_one(); // just send out a signal
if(m_thread) m_thread->join(); // and wait for end
m_state = -1;
return m_state;
}
示例12: 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);
};
示例13: StopDispaching
int WorkManagerImpl::StopDispaching()
{
// lock nothing coz care nothing ...
if(m_state <= 0) return m_state;
m_state = 0;
m_workreq = 1;
m_condition.notify_one(); // just send out a signal
if(m_dispatcherthread) m_dispatcherthread->join(); // and wait for end
m_state = -1;
return m_state;
}
示例14: finishProcess
void finishProcess() {
while (mode == WAITING) {
boost::this_thread::sleep(boost::posix_time::seconds(1));
}
ROS_INFO("Finished");
if (mode == SLAM)
killMapping();
if (mode == LOCALIZATION)
killLocalization();
if (mode == OUTDOOR)
killOutdoorMode();
mappingProcessThread.join();
}
示例15: join
void join() {
//terminated = true;
m_Thread.join();
std::cout << "[DIS] Thread Terminated\n";
media->messageQueue->terminated = true;
}