bool SystemProfiler::_ThreadAdded(Thread* thread) { ThreadLocker threadLocker(thread); InterruptsSpinLocker locker(fLock); // During the initial scan check whether the team is already gone again. // Later this cannot happen, since the team creator notifies us before // actually starting the thread. if (!fThreadNotificationsEnabled && !thread->IsAlive()) return true; if (thread->serial_number > fLastThreadAddedSerialNumber) fLastThreadAddedSerialNumber = thread->serial_number; system_profiler_thread_added* event = (system_profiler_thread_added*) _AllocateBuffer(sizeof(system_profiler_thread_added), B_SYSTEM_PROFILER_THREAD_ADDED, 0, 0); if (event == NULL) return false; event->team = thread->team->id; event->thread = thread->id; strlcpy(event->name, thread->name, sizeof(event->name)); fHeader->size = fBufferSize; return true; }
bool SystemProfiler::_ThreadRemoved(Thread* thread) { // TODO: It is possible that we get remove notifications for threads that // had already been removed from the global thread list when we did the // initial scan, but were still in the process of dying. ATM it is not // really possible to identify such a case. ThreadLocker threadLocker(thread); InterruptsSpinLocker locker(fLock); system_profiler_thread_removed* event = (system_profiler_thread_removed*) _AllocateBuffer(sizeof(system_profiler_thread_removed), B_SYSTEM_PROFILER_THREAD_REMOVED, 0, 0); if (event == NULL) return false; event->team = thread->team->id; event->thread = thread->id; fHeader->size = fBufferSize; return true; }
void AAPIO::threadFinished(AAPIOSelect * thread) { Gate g(this, "threadFinished()"); QMutexLocker threadLocker(&threadMutex); if (thread == select) { select = NULL; } thread->deleteLater(); }