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


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

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


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

示例1: Update

	bool Update(thread_id threadID)
	{
		if (fTeam == NULL) {
			for (int32 i = 0; Thread* thread = fThreads.ItemAt(i); i++)
				thread->ReleaseReference();
			fThreads.MakeEmpty();

			return true;
		}

		AutoLocker<Team> locker(fTeam);

		ThreadList::ConstIterator it = fTeam->Threads().GetIterator();
		Thread* newThread = it.Next();
		int32 index = 0;

		// remove no longer existing threads
		while (Thread* oldThread = fThreads.ItemAt(index)) {
			if (oldThread == newThread) {
				if (threadID >= 0 && oldThread->ID() == threadID)
					NotifyRowsChanged(index, 1);
				index++;
				newThread = it.Next();
			} else {
				// TODO: Not particularly efficient!
				fThreads.RemoveItemAt(index);
				oldThread->ReleaseReference();
				NotifyRowsRemoved(index, 1);
			}
		}

		// add new threads
		int32 countBefore = fThreads.CountItems();
		while (newThread != NULL) {
			if (!fThreads.AddItem(newThread))
				return false;

			newThread->AcquireReference();
			newThread = it.Next();
		}

		int32 count = fThreads.CountItems();
		if (count > countBefore)
			NotifyRowsAdded(countBefore, count - countBefore);

		return true;
	}
开发者ID:,项目名称:,代码行数:47,代码来源:

示例2: locker

bigtime_t
_user_estimate_max_scheduling_latency(thread_id id)
{
	syscall_64_bit_return_value();

	// get the thread
	Thread* thread;
	if (id < 0) {
		thread = thread_get_current_thread();
		thread->AcquireReference();
	} else {
		thread = Thread::Get(id);
		if (thread == NULL)
			return 0;
	}
	BReference<Thread> threadReference(thread, true);

	// ask the scheduler for the thread's latency
	InterruptsSpinLocker locker(gSchedulerLock);
	return gScheduler->estimate_max_scheduling_latency(thread);
}
开发者ID:mmadia,项目名称:Haiku-services-branch,代码行数:21,代码来源:scheduler.cpp


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