Ignore:
Timestamp:
Sep 3, 2008, 9:37:00 AM (17 years ago)
Author:
[email protected]
Message:

Reviewed by Darin Adler.

Implement callOnMainThreadAndWait().

This will be useful when a background thread needs to perform UI calls synchronously
(e.g. an openDatabase() call cannot return until the user answers to a confirmation dialog).

  • wtf/MainThread.cpp: (WTF::FunctionWithContext::FunctionWithContext): Added a ThreadCondition member. When non-zero, the condition is signalled after the function is called. (WTF::mainThreadFunctionQueueMutex): Renamed from functionQueueMutex, sinc this is no longer static. Changed to be initialized from initializeThreading() to avoid lock contention. (WTF::initializeMainThread): On non-Windows platforms, just call mainThreadFunctionQueueMutex. (WTF::dispatchFunctionsFromMainThread): Signal synchronous calls when done. (WTF::callOnMainThread): Updated for functionQueueMutex rename. (WTF::callOnMainThreadAndWait): Added.
  • wtf/MainThread.h: Added callOnMainThreadAndWait(); initializeMainThread() now exists on all platforms.
  • wtf/win/MainThreadWin.cpp: (WTF::initializeMainThread): Added a callOnMainThreadAndWait() call to initialize function queue mutex.
  • wtf/ThreadingGtk.cpp: (WTF::initializeThreading):
  • wtf/ThreadingPthreads.cpp: (WTF::initializeThreading):
  • wtf/ThreadingQt.cpp: (WTF::initializeThreading): Only initialize mainThreadIdentifier on non-Darwin platforms. It was not guaranteed to be accurate on Darwin.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/wtf/MainThread.h

    r31730 r36056  
    3333namespace WTF {
    3434
     35class Mutex;
     36
    3537typedef void MainThreadFunction(void*);
    3638
    3739void callOnMainThread(MainThreadFunction*, void* context);
     40void callOnMainThreadAndWait(MainThreadFunction*, void* context);
     41
    3842void setMainThreadCallbacksPaused(bool paused);
    3943
    40 #if PLATFORM(WIN)
     44// Must be called from the main thread (Darwin is an exception to this rule).
    4145void initializeMainThread();
    42 #endif
    4346
    4447// These functions are internal to the callOnMainThread implementation.
    4548void dispatchFunctionsFromMainThread();
    4649void scheduleDispatchFunctionsOnMainThread();
     50Mutex& mainThreadFunctionQueueMutex();
    4751
    4852} // namespace WTF
Note: See TracChangeset for help on using the changeset viewer.