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


C++ Thread::State方法代码示例

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


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

示例1: teamLocker

bool
CommandLineUserInterface::_ReportTargetThreadStopNeeded() const
{
	if (fReportTargetThread < 0)
		return false;

	Team* team = fContext.GetTeam();
	AutoLocker<Team> teamLocker(team);
	Thread* thread = team->ThreadByID(fReportTargetThread);
	if (thread == NULL)
		return false;

	return thread->State() != THREAD_STATE_STOPPED;
}
开发者ID:DonCN,项目名称:haiku,代码行数:14,代码来源:CommandLineUserInterface.cpp

示例2: GetToolTipForTableCell

	virtual bool GetToolTipForTableCell(int32 rowIndex, int32 columnIndex,
		BToolTip** _tip)
	{
		Thread* thread = fThreads.ItemAt(rowIndex);
		if (thread == NULL)
			return false;

		BString text;
		text << "Thread: \"" << thread->Name() << "\" (" << thread->ID()
			<< ")\n";

		switch (thread->State()) {
			case THREAD_STATE_RUNNING:
				text << "Running";
				break;
			case THREAD_STATE_STOPPED:
			{
				switch (thread->StoppedReason()) {
					case THREAD_STOPPED_DEBUGGER_CALL:
						text << "Called debugger(): "
							<< thread->StoppedReasonInfo();
						break;
					case THREAD_STOPPED_EXCEPTION:
						text << "Caused exception: "
							<< thread->StoppedReasonInfo();
						break;
					case THREAD_STOPPED_BREAKPOINT:
					case THREAD_STOPPED_WATCHPOINT:
					case THREAD_STOPPED_SINGLE_STEP:
					case THREAD_STOPPED_DEBUGGED:
					case THREAD_STOPPED_UNKNOWN:
					default:
						text << "Stopped for debugging";
						break;
				}
				break;
			}
			case THREAD_STATE_UNKNOWN:
			default:
				text << "Current State Unknown";
				break;
		}

		BTextToolTip* tip = new(std::nothrow) BTextToolTip(text);
		if (tip == NULL)
			return false;

		*_tip = tip;
		return true;
	}
开发者ID:,项目名称:,代码行数:50,代码来源:

示例3: GetValueAt

	virtual bool GetValueAt(int32 rowIndex, int32 columnIndex, BVariant& value)
	{
		Thread* thread = fThreads.ItemAt(rowIndex);
		if (thread == NULL)
			return false;

		switch (columnIndex) {
			case 0:
				value.SetTo(thread->ID());
				return true;
			case 1:
			{
				switch (thread->State()) {
					case THREAD_STATE_RUNNING:
						value.SetTo("Running", B_VARIANT_DONT_COPY_DATA);
						return true;
					case THREAD_STATE_STOPPED:
						break;
					case THREAD_STATE_UNKNOWN:
					default:
						value.SetTo("?", B_VARIANT_DONT_COPY_DATA);
						return true;
				}

				// thread is stopped -- get the reason
				switch (thread->StoppedReason()) {
					case THREAD_STOPPED_DEBUGGER_CALL:
						value.SetTo("Call", B_VARIANT_DONT_COPY_DATA);
						return true;
					case THREAD_STOPPED_EXCEPTION:
						value.SetTo("Exception", B_VARIANT_DONT_COPY_DATA);
						return true;
					case THREAD_STOPPED_BREAKPOINT:
					case THREAD_STOPPED_WATCHPOINT:
					case THREAD_STOPPED_SINGLE_STEP:
					case THREAD_STOPPED_DEBUGGED:
					case THREAD_STOPPED_UNKNOWN:
					default:
						value.SetTo("Debugged", B_VARIANT_DONT_COPY_DATA);
						return true;
				}
			}
			case 2:
				value.SetTo(thread->Name(), B_VARIANT_DONT_COPY_DATA);
				return true;
			default:
				return false;
		}
	}
开发者ID:,项目名称:,代码行数:49,代码来源:

示例4:

void
CommandLineUserInterface::ThreadStateChanged(const Team::ThreadEvent& event)
{
	if (fSaveReport) {
		Thread* thread = event.GetThread();
		// If we were asked to attach/report on a specific thread
		// rather than a team, and said thread was still
		// running, when we attached, we need to wait for its corresponding
		// stop state before generating a report, else we might not get its
		// stack trace.
		if (thread->ID() == fReportTargetThread
			&& thread->State() == THREAD_STATE_STOPPED) {
			_SubmitSaveReport();
		}
	}
}
开发者ID:DonCN,项目名称:haiku,代码行数:16,代码来源:CommandLineUserInterface.cpp

示例5: teamLocker

void
CliStackTraceCommand::Execute(int argc, const char* const* argv,
	CliContext& context)
{
	// get the current thread
	Team* team = context.GetTeam();
	AutoLocker<Team> teamLocker(team);
	Thread* thread = context.CurrentThread();
	if (thread == NULL) {
		printf("no current thread\n");
		return;
	}

	if (thread->State() != THREAD_STATE_STOPPED) {
		printf("Current thread is not stopped. Can't get stack trace.\n");
		return;
	}

	// get its stack trace
	StackTrace* stackTrace = thread->GetStackTrace();
	while (stackTrace == NULL) {
		context.WaitForEvents(CliContext::EVENT_THREAD_STACK_TRACE_CHANGED);
		if (context.IsTerminating())
			return;
		stackTrace = thread->GetStackTrace();
	}
	BReference<StackTrace> stackTraceReference(stackTrace);
		// hold a reference until we're done

	teamLocker.Unlock();

	// print the stack trace
	int32 frameCount = stackTrace->CountFrames();
	for (int32 i = 0; i < frameCount; i++) {
		StackFrame* frame = stackTrace->FrameAt(i);
		printf("%3" B_PRId32 "  %#" B_PRIx64 "  %#" B_PRIx64, i,
			(uint64)frame->FrameAddress(), (uint64)frame->InstructionPointer());

		char functionName[512];
		UiUtils::FunctionNameForFrame(frame, functionName,
			sizeof(functionName));
		printf("  %s\n", functionName);
	}
}
开发者ID:AmirAbrams,项目名称:haiku,代码行数:44,代码来源:CliStackTraceCommand.cpp


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