当前位置: 首页>>代码示例>>C++>>正文


C++ WorkItem::Run方法代码示例

本文整理汇总了C++中WorkItem::Run方法的典型用法代码示例。如果您正苦于以下问题:C++ WorkItem::Run方法的具体用法?C++ WorkItem::Run怎么用?C++ WorkItem::Run使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在WorkItem的用法示例。


在下文中一共展示了WorkItem::Run方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: while

void WorkItemQueue::Process()
{
	while (!m_dying) {
		WorkItem* item = NULL;
		boost::unique_lock<boost::mutex> lock(m_mutex);
		while ((!m_dying) && (item = Pop())) {
			try {
				//                LslDebug( "running WorkItem %p, prio = %d", item, item->m_priority );
				item->Run();
			} catch (std::exception& e) {
				// better eat all exceptions thrown by WorkItem::Run(),
				// don't want to let the thread die on a single faulty WorkItem.
				LslDebug("WorkerThread caught exception thrown by WorkItem::Run -- %s", e.what());
			} catch (...) {
				LslDebug("WorkerThread caught exception thrown by WorkItem::Run");
			}
			CleanupWorkItem(item);
		}
		// cleanup leftover WorkItems
		while ((item = Pop()) != NULL) {
			CleanupWorkItem(item);
		}
		if (!m_dying)
			//wait for the next Push
			m_cond.wait(lock);
	}
}
开发者ID:apoleon,项目名称:lsl,代码行数:27,代码来源:thread.cpp

示例2: wxLogMessage

void* WorkerThread::Entry()
{
	WorkItem* item;

	wxLogMessage( _T( "WorkerThread started" ) );

	while ( !TestDestroy() ) {
		// sleep an hour or until a new WorkItem arrives (DoWork() will wake us up).
		Sleep( 3600 * 1000 );
		while ( !TestDestroy() && ( item = m_workItems.Pop() ) != NULL ) {
			try {
				wxLogMessage( _T( "running WorkItem %p, prio = %d" ), item, item->m_priority );
				item->Run();
			}
			catch ( ... ) {
				// better eat all exceptions thrown by WorkItem::Run(),
				// don't want to let the thread die on a single faulty WorkItem.
				wxLogMessage( _T( "WorkerThread caught exception thrown by WorkItem::Run" ) );
			}
			CleanupWorkItem( item );
			// give other threads some air
			Yield();
		}
	}

	// cleanup leftover WorkItems
	while ( ( item = m_workItems.Pop() ) != NULL ) {
		CleanupWorkItem( item );
	}

	wxLogMessage( _T( "WorkerThread stopped" ) );
	return 0;
}
开发者ID:N2maniac,项目名称:springlobby-join-fork,代码行数:33,代码来源:thread.cpp


注:本文中的WorkItem::Run方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。