本文整理汇总了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;
}
示例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);
}