Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Use std::chrono functions in dispatchFunctionsFromMainThread()
https://bugs.webkit.org/show_bug.cgi?id=128308

Reviewed by Antti Koivisto.

* wtf/MainThread.cpp:
(WTF::dispatchFunctionsFromMainThread):

Canonical link: https://commits.webkit.org/146320@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@163536 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
Anders Carlsson committed Feb 6, 2014
1 parent 015a1de commit ccfcc14
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 3 deletions.
10 changes: 10 additions & 0 deletions Source/WTF/ChangeLog
@@ -1,3 +1,13 @@
2014-02-06 Anders Carlsson <andersca@apple.com>

Use std::chrono functions in dispatchFunctionsFromMainThread()
https://bugs.webkit.org/show_bug.cgi?id=128308

Reviewed by Antti Koivisto.

* wtf/MainThread.cpp:
(WTF::dispatchFunctionsFromMainThread):

2014-02-05 Zan Dobersek <zdobersek@igalia.com>

Remove the WTF_COMPILER_SUPPORTS_CXX_GENERALIZED_INITIALIZERS macro
Expand Down
6 changes: 3 additions & 3 deletions Source/WTF/wtf/MainThread.cpp
Expand Up @@ -142,7 +142,7 @@ void initializeWebThread()
#endif

// 0.1 sec delays in UI is approximate threshold when they become noticeable. Have a limit that's half of that.
static const double maxRunLoopSuspensionTime = 0.05;
static const auto maxRunLoopSuspensionTime = std::chrono::milliseconds(50);

void dispatchFunctionsFromMainThread()
{
Expand All @@ -151,7 +151,7 @@ void dispatchFunctionsFromMainThread()
if (callbacksPaused)
return;

double startTime = monotonicallyIncreasingTime();
auto startTime = std::chrono::steady_clock::now();

FunctionWithContext invocation;
while (true) {
Expand All @@ -168,7 +168,7 @@ void dispatchFunctionsFromMainThread()
// yield so the user input can be processed. Otherwise user may not be able to even close the window.
// This code has effect only in case the scheduleDispatchFunctionsOnMainThread() is implemented in a way that
// allows input events to be processed before we are back here.
if (monotonicallyIncreasingTime() - startTime > maxRunLoopSuspensionTime) {
if (std::chrono::steady_clock::now() - startTime > maxRunLoopSuspensionTime) {
scheduleDispatchFunctionsOnMainThread();
break;
}
Expand Down

0 comments on commit ccfcc14

Please sign in to comment.