void WorkletBackingThreadHolder::shutdownAndWait() {
  DCHECK(isMainThread());
  WaitableEvent waitableEvent;
  m_thread->backingThread().postTask(
      BLINK_FROM_HERE,
      crossThreadBind(&WorkletBackingThreadHolder::shutdownOnThread,
                      crossThreadUnretained(this),
                      crossThreadUnretained(&waitableEvent)));
  waitableEvent.wait();
}
void HTMLParserThread::shutdown()
{
    ASSERT(isMainThread());
    ASSERT(s_sharedThread);
    // currentThread will always be non-null in production, but can be null in Chromium unit tests.
    if (Platform::current()->currentThread() && s_sharedThread->m_thread) {
        WaitableEvent waitableEvent;
        s_sharedThread->postTask(threadSafeBind(&HTMLParserThread::cleanupHTMLParserThread, AllowCrossThreadAccess(s_sharedThread), AllowCrossThreadAccess(&waitableEvent)));
        SafePointScope scope(BlinkGC::HeapPointersOnStack);
        waitableEvent.wait();
    }
    delete s_sharedThread;
    s_sharedThread = nullptr;
}
std::unique_ptr<CompositorMutatorClient> CompositorMutatorImpl::createClient()
{
    std::unique_ptr<CompositorMutatorClient> mutatorClient;
    WaitableEvent doneEvent;
    if (WebThread* compositorThread = Platform::current()->compositorThread()) {
        compositorThread->getWebTaskRunner()->postTask(BLINK_FROM_HERE, crossThreadBind(&createCompositorMutatorClient, crossThreadUnretained(&mutatorClient), crossThreadUnretained(&doneEvent)));
    } else {
        createCompositorMutatorClient(&mutatorClient, &doneEvent);
    }
    // TODO(flackr): Instead of waiting for this event, we may be able to just set the
    // mutator on the CompositorProxyClient directly from the compositor thread before
    // it gets used there. We still need to make sure we only create one mutator though.
    doneEvent.wait();
    return mutatorClient;
}
Exemplo n.º 4
0
void HTMLParserThread::shutdown() {
  ASSERT(isMainThread());
  ASSERT(s_sharedThread);
  // currentThread will always be non-null in production, but can be null in
  // Chromium unit tests.
  if (Platform::current()->currentThread() && s_sharedThread->m_thread) {
    WaitableEvent waitableEvent;
    s_sharedThread->postTask(
        crossThreadBind(&HTMLParserThread::cleanupHTMLParserThread,
                        crossThreadUnretained(s_sharedThread),
                        crossThreadUnretained(&waitableEvent)));
    waitableEvent.wait();
  }
  delete s_sharedThread;
  s_sharedThread = nullptr;
}
Exemplo n.º 5
0
void DatabaseThread::terminate() {
  ASSERT(isMainThread());
  WaitableEvent sync;
  {
    MutexLocker lock(m_terminationRequestedMutex);
    ASSERT(!m_terminationRequested);
    m_terminationRequested = true;
    m_cleanupSync = &sync;
    STORAGE_DVLOG(1) << "DatabaseThread " << this << " was asked to terminate";
    m_thread->postTask(BLINK_FROM_HERE,
                       crossThreadBind(&DatabaseThread::cleanupDatabaseThread,
                                       wrapCrossThreadPersistent(this)));
  }
  sync.wait();
  // The WebThread destructor blocks until all the tasks of the database
  // thread are processed. However, it shouldn't block at all because
  // the database thread has already finished processing the cleanup task.
  m_thread.reset();
}
Exemplo n.º 6
0
 void asyncHandlersComplete()
 {
     m_event.signal ();
 }
Exemplo n.º 7
0
 void stop ()
 {
     stop_async ();
     m_event.wait();
 }