Changeset 31198 in webkit


Ignore:
Timestamp:
Mar 20, 2008 5:14:31 PM (16 years ago)
Author:
Adam Roben
Message:

Allow pausing of callOnMainThread callbacks

Part of Bug 17133: Should support pausing JavaScript execution without
hanging the process

<http://bugs.webkit.org/show_bug.cgi?id=17133>
<rdar://problem/5719551>

Reviewed by Tim Hatcher.

  • platform/MainThread.cpp: (WebCore::dispatchFunctionsFromMainThread): If callbacks are paused, don't dispatch the functions. (WebCore::setMainThreadCallbacksPaused): Added. If we're being unpaused, call scheduleDispatchFunctionsOnMainThread so that any queued callbacks will get dispatched in the near future.
  • platform/MainThread.h:
Location:
trunk/WebCore
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r31197 r31198  
     12008-03-20  Adam Roben  <aroben@apple.com>
     2
     3        Allow pausing of callOnMainThread callbacks
     4
     5        Part of Bug 17133: Should support pausing JavaScript execution without
     6        hanging the process
     7
     8        <http://bugs.webkit.org/show_bug.cgi?id=17133>
     9        <rdar://problem/5719551>
     10
     11        Reviewed by Tim Hatcher.
     12
     13        * platform/MainThread.cpp:
     14        (WebCore::dispatchFunctionsFromMainThread): If callbacks are paused,
     15        don't dispatch the functions.
     16        (WebCore::setMainThreadCallbacksPaused): Added. If we're being
     17        unpaused, call scheduleDispatchFunctionsOnMainThread so that any
     18        queued callbacks will get dispatched in the near future.
     19        * platform/MainThread.h:
     20
    1212008-03-20  Adam Roben  <aroben@apple.com>
    222
  • trunk/WebCore/platform/MainThread.cpp

    r31068 r31198  
    4343typedef Vector<FunctionWithContext> FunctionQueue;
    4444
     45static bool callbacksPaused;
     46
    4547static Mutex& functionQueueMutex()
    4648{
     
    5759void dispatchFunctionsFromMainThread()
    5860{
     61    if (callbacksPaused)
     62        return;
     63
    5964    FunctionQueue queueCopy;
    6065    {
     
    8085}
    8186
     87void setMainThreadCallbacksPaused(bool paused)
     88{
     89    if (callbacksPaused == paused)
     90        return;
     91
     92    callbacksPaused = paused;
     93
     94    if (!callbacksPaused)
     95        scheduleDispatchFunctionsOnMainThread();
     96}
     97
    8298} // namespace WebCore
  • trunk/WebCore/platform/MainThread.h

    r31063 r31198  
    3838
    3939void callOnMainThread(MainThreadFunction*, void* context);
     40void setMainThreadCallbacksPaused(bool paused);
    4041
    4142void initializeThreadingAndMainThread();
Note: See TracChangeset for help on using the changeset viewer.