Diff
Modified: trunk/Source/_javascript_Core/ChangeLog (213857 => 213858)
--- trunk/Source/_javascript_Core/ChangeLog 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/_javascript_Core/ChangeLog 2017-03-13 18:56:54 UTC (rev 213858)
@@ -1,3 +1,13 @@
+2017-03-13 Yusuke Suzuki <[email protected]>
+
+ [WTF] Clean up RunLoop and WorkQueue with Seconds and Function
+ https://bugs.webkit.org/show_bug.cgi?id=169537
+
+ Reviewed by Sam Weinig.
+
+ * runtime/Watchdog.cpp:
+ (JSC::Watchdog::startTimer):
+
2017-03-11 Filip Pizlo <[email protected]>
FTL should not flush strict arguments unless it really needs to
Modified: trunk/Source/_javascript_Core/runtime/Watchdog.cpp (213857 => 213858)
--- trunk/Source/_javascript_Core/runtime/Watchdog.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/_javascript_Core/runtime/Watchdog.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -158,7 +158,7 @@
// So, we always need to null check m_vm before using it. The VM will notify the Watchdog
// via willDestroyVM() before it goes away.
RefPtr<Watchdog> protectedThis = this;
- m_timerQueue->dispatchAfter(std::chrono::nanoseconds(timeLimit), [this, protectedThis] {
+ m_timerQueue->dispatchAfter(Seconds::fromMicroseconds(timeLimit.count()), [this, protectedThis] {
LockHolder locker(m_lock);
if (m_vm)
m_vm->notifyNeedWatchdogCheck();
Modified: trunk/Source/WTF/ChangeLog (213857 => 213858)
--- trunk/Source/WTF/ChangeLog 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/ChangeLog 2017-03-13 18:56:54 UTC (rev 213858)
@@ -1,3 +1,48 @@
+2017-03-13 Yusuke Suzuki <[email protected]>
+
+ [WTF] Clean up RunLoop and WorkQueue with Seconds and Function
+ https://bugs.webkit.org/show_bug.cgi?id=169537
+
+ Reviewed by Sam Weinig.
+
+ This patch modernizes RunLoop and WorkQueue.
+
+ 1. Use Ref<> aggressively
+ 2. Use Seconds instead of chrono times
+ 3. Use Function<> instead of std::function
+
+ * wtf/MainThread.cpp:
+ (WTF::dispatchFunctionsFromMainThread):
+ * wtf/RunLoop.h:
+ * wtf/WorkQueue.h:
+ * wtf/cocoa/WorkQueueCocoa.cpp:
+ (WTF::WorkQueue::dispatch):
+ (WTF::WorkQueue::dispatchAfter):
+ (WTF::WorkQueue::concurrentApply):
+ * wtf/generic/MainThreadGeneric.cpp:
+ (WTF::scheduleDispatchFunctionsOnMainThread):
+ * wtf/generic/RunLoopGeneric.cpp:
+ (WTF::RunLoop::TimerBase::ScheduledTask::create):
+ (WTF::RunLoop::TimerBase::ScheduledTask::EarliestSchedule::operator()):
+ (WTF::RunLoop::populateTasks):
+ (WTF::RunLoop::runImpl):
+ (WTF::RunLoop::schedule):
+ (WTF::RunLoop::scheduleAndWakeUp):
+ (WTF::RunLoop::dispatchAfter):
+ (WTF::RunLoop::TimerBase::start):
+ * wtf/generic/WorkQueueGeneric.cpp:
+ (WorkQueue::dispatch):
+ (WorkQueue::dispatchAfter):
+ * wtf/glib/RunLoopGLib.cpp:
+ (WTF::DispatchAfterContext::DispatchAfterContext):
+ (WTF::RunLoop::dispatchAfter):
+ (WTF::RunLoop::TimerBase::updateReadyTime):
+ (WTF::RunLoop::TimerBase::start):
+ * wtf/win/WorkQueueWin.cpp:
+ (WTF::WorkQueue::performWorkOnRegisteredWorkThread):
+ (WTF::WorkQueue::dispatch):
+ (WTF::WorkQueue::dispatchAfter):
+
2017-03-13 Chris Dumez <[email protected]>
[WK2] Only report background WebProcesses as unresponsive in the background after 90 seconds
Modified: trunk/Source/WTF/wtf/MainThread.cpp (213857 => 213858)
--- trunk/Source/WTF/wtf/MainThread.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/MainThread.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -111,7 +111,7 @@
#endif
// 0.1 sec delays in UI is approximate threshold when they become noticeable. Have a limit that's half of that.
-static const auto maxRunLoopSuspensionTime = std::chrono::milliseconds(50);
+static const auto maxRunLoopSuspensionTime = 50_ms;
void dispatchFunctionsFromMainThread()
{
@@ -120,7 +120,7 @@
if (callbacksPaused)
return;
- auto startTime = std::chrono::steady_clock::now();
+ auto startTime = MonotonicTime::now();
Function<void ()> function;
@@ -142,7 +142,7 @@
// 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 (std::chrono::steady_clock::now() - startTime > maxRunLoopSuspensionTime) {
+ if (MonotonicTime::now() - startTime > maxRunLoopSuspensionTime) {
scheduleDispatchFunctionsOnMainThread();
break;
}
Modified: trunk/Source/WTF/wtf/RunLoop.h (213857 => 213858)
--- trunk/Source/WTF/wtf/RunLoop.h 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/RunLoop.h 2017-03-13 18:56:54 UTC (rev 213858)
@@ -34,6 +34,7 @@
#include <wtf/FunctionDispatcher.h>
#include <wtf/HashMap.h>
#include <wtf/RetainPtr.h>
+#include <wtf/Seconds.h>
#include <wtf/Threading.h>
#if USE(GLIB_EVENT_LOOP)
@@ -54,7 +55,7 @@
WTF_EXPORT_PRIVATE static bool isMain();
~RunLoop();
- void dispatch(Function<void ()>&&) override;
+ void dispatch(Function<void()>&&) override;
WTF_EXPORT_PRIVATE static void run();
WTF_EXPORT_PRIVATE void stop();
@@ -74,7 +75,7 @@
#endif
#if USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP)
- WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, Function<void ()>&&);
+ WTF_EXPORT_PRIVATE void dispatchAfter(Seconds, Function<void()>&&);
#endif
class TimerBase {
@@ -115,7 +116,7 @@
void updateReadyTime();
GRefPtr<GSource> m_source;
bool m_isRepeating { false };
- std::chrono::microseconds m_fireInterval { 0 };
+ Seconds m_fireInterval { 0 };
#elif USE(GENERIC_EVENT_LOOP)
class ScheduledTask;
RefPtr<ScheduledTask> m_scheduledTask;
@@ -149,7 +150,7 @@
void performWork();
Mutex m_functionQueueLock;
- Deque<Function<void ()>> m_functionQueue;
+ Deque<Function<void()>> m_functionQueue;
#if USE(WINDOWS_EVENT_LOOP)
static bool registerRunLoopMessageWindowClass();
@@ -168,10 +169,10 @@
Vector<GRefPtr<GMainLoop>> m_mainLoops;
GRefPtr<GSource> m_source;
#elif USE(GENERIC_EVENT_LOOP)
- void schedule(RefPtr<TimerBase::ScheduledTask>&&);
- void schedule(const AbstractLocker&, RefPtr<TimerBase::ScheduledTask>&&);
+ void schedule(Ref<TimerBase::ScheduledTask>&&);
+ void schedule(const AbstractLocker&, Ref<TimerBase::ScheduledTask>&&);
void wakeUp(const AbstractLocker&);
- void scheduleAndWakeUp(RefPtr<TimerBase::ScheduledTask>);
+ void scheduleAndWakeUp(Ref<TimerBase::ScheduledTask>&&);
enum class RunMode {
Iterate,
@@ -183,12 +184,12 @@
Stopping,
};
void runImpl(RunMode);
- bool populateTasks(RunMode, Status&, Deque<RefPtr<TimerBase::ScheduledTask>>&);
+ bool populateTasks(RunMode, Status&, Deque<Ref<TimerBase::ScheduledTask>>&);
Lock m_loopLock;
Condition m_readyToRun;
Condition m_stopCondition;
- Vector<RefPtr<TimerBase::ScheduledTask>> m_schedules;
+ Vector<Ref<TimerBase::ScheduledTask>> m_schedules;
Vector<Status*> m_mainLoops;
bool m_shutdown { false };
bool m_pendingTasks { false };
Modified: trunk/Source/WTF/wtf/WorkQueue.h (213857 => 213858)
--- trunk/Source/WTF/wtf/WorkQueue.h 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/WorkQueue.h 2017-03-13 18:56:54 UTC (rev 213858)
@@ -27,11 +27,11 @@
#ifndef WorkQueue_h
#define WorkQueue_h
-#include <chrono>
#include <functional>
#include <wtf/Forward.h>
#include <wtf/FunctionDispatcher.h>
#include <wtf/RefCounted.h>
+#include <wtf/Seconds.h>
#include <wtf/Threading.h>
#if USE(COCOA_EVENT_LOOP)
@@ -66,10 +66,10 @@
WTF_EXPORT_PRIVATE static Ref<WorkQueue> create(const char* name, Type = Type::Serial, QOS = QOS::Default);
virtual ~WorkQueue();
- WTF_EXPORT_PRIVATE void dispatch(Function<void ()>&&) override;
- WTF_EXPORT_PRIVATE void dispatchAfter(std::chrono::nanoseconds, Function<void ()>&&);
+ WTF_EXPORT_PRIVATE void dispatch(Function<void()>&&) override;
+ WTF_EXPORT_PRIVATE void dispatchAfter(Seconds, Function<void()>&&);
- WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, const std::function<void (size_t index)>&);
+ WTF_EXPORT_PRIVATE static void concurrentApply(size_t iterations, const std::function<void(size_t index)>&);
#if USE(COCOA_EVENT_LOOP)
dispatch_queue_t dispatchQueue() const { return m_dispatchQueue; }
@@ -99,7 +99,7 @@
volatile LONG m_isWorkThreadRegistered;
Mutex m_functionQueueLock;
- Vector<Function<void ()>> m_functionQueue;
+ Vector<Function<void()>> m_functionQueue;
HANDLE m_timerQueue;
#elif USE(GLIB_EVENT_LOOP) || USE(GENERIC_EVENT_LOOP)
Modified: trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp (213857 => 213858)
--- trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/cocoa/WorkQueueCocoa.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -30,16 +30,16 @@
namespace WTF {
-void WorkQueue::dispatch(Function<void ()>&& function)
+void WorkQueue::dispatch(Function<void()>&& function)
{
- dispatch_async(m_dispatchQueue, BlockPtr<void ()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] {
+ dispatch_async(m_dispatchQueue, BlockPtr<void()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] {
function();
}).get());
}
-void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, Function<void ()>&& function)
+void WorkQueue::dispatchAfter(Seconds duration, Function<void()>&& function)
{
- dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.count()), m_dispatchQueue, BlockPtr<void ()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] {
+ dispatch_after(dispatch_time(DISPATCH_TIME_NOW, duration.nanoseconds()), m_dispatchQueue, BlockPtr<void()>::fromCallable([protectedThis = makeRef(*this), function = WTFMove(function)] {
function();
}).get());
}
@@ -100,7 +100,7 @@
dispatch_release(m_dispatchQueue);
}
-void WorkQueue::concurrentApply(size_t iterations, const std::function<void (size_t index)>& function)
+void WorkQueue::concurrentApply(size_t iterations, const std::function<void(size_t index)>& function)
{
dispatch_apply(iterations, dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^(size_t index) {
function(index);
Modified: trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp (213857 => 213858)
--- trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/generic/MainThreadGeneric.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -37,7 +37,7 @@
void scheduleDispatchFunctionsOnMainThread()
{
- RunLoop::main().dispatch(std::function<void()>(dispatchFunctionsFromMainThread));
+ RunLoop::main().dispatch(Function<void()>(&dispatchFunctionsFromMainThread));
}
}
Modified: trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp (213857 => 213858)
--- trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/generic/RunLoopGeneric.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -32,9 +32,9 @@
class RunLoop::TimerBase::ScheduledTask : public ThreadSafeRefCounted<ScheduledTask> {
WTF_MAKE_NONCOPYABLE(ScheduledTask);
public:
- static RefPtr<ScheduledTask> create(Function<void()>&& function, Seconds interval, bool repeating)
+ static Ref<ScheduledTask> create(Function<void()>&& function, Seconds interval, bool repeating)
{
- return adoptRef(new ScheduledTask(WTFMove(function), interval, repeating));
+ return adoptRef(*new ScheduledTask(WTFMove(function), interval, repeating));
}
ScheduledTask(Function<void()>&& function, Seconds interval, bool repeating)
@@ -73,7 +73,7 @@
}
struct EarliestSchedule {
- bool operator()(const RefPtr<ScheduledTask>& lhs, const RefPtr<ScheduledTask>& rhs)
+ bool operator()(const Ref<ScheduledTask>& lhs, const Ref<ScheduledTask>& rhs)
{
return lhs->scheduledTimePoint() > rhs->scheduledTimePoint();
}
@@ -112,7 +112,7 @@
m_stopCondition.wait(m_loopLock);
}
-inline bool RunLoop::populateTasks(RunMode runMode, Status& statusOfThisLoop, Deque<RefPtr<TimerBase::ScheduledTask>>& firedTimers)
+inline bool RunLoop::populateTasks(RunMode runMode, Status& statusOfThisLoop, Deque<Ref<TimerBase::ScheduledTask>>& firedTimers)
{
LockHolder locker(m_loopLock);
@@ -139,12 +139,12 @@
// Check expired timers.
MonotonicTime now = MonotonicTime::now();
while (!m_schedules.isEmpty()) {
- RefPtr<TimerBase::ScheduledTask> earliest = m_schedules.first();
+ Ref<TimerBase::ScheduledTask> earliest = m_schedules.first().copyRef();
if (earliest->scheduledTimePoint() > now)
break;
std::pop_heap(m_schedules.begin(), m_schedules.end(), TimerBase::ScheduledTask::EarliestSchedule());
m_schedules.removeLast();
- firedTimers.append(earliest);
+ firedTimers.append(WTFMove(earliest));
}
return true;
@@ -160,7 +160,7 @@
m_mainLoops.append(&statusOfThisLoop);
}
- Deque<RefPtr<TimerBase::ScheduledTask>> firedTimers;
+ Deque<Ref<TimerBase::ScheduledTask>> firedTimers;
while (true) {
if (!populateTasks(runMode, statusOfThisLoop, firedTimers))
return;
@@ -167,7 +167,7 @@
// Dispatch scheduled timers.
while (!firedTimers.isEmpty()) {
- RefPtr<TimerBase::ScheduledTask> task = firedTimers.takeFirst();
+ Ref<TimerBase::ScheduledTask> task = firedTimers.takeFirst();
if (task->fired()) {
// Reschedule because the timer requires repeating.
// Since we will query the timers' time points before sleeping,
@@ -218,19 +218,19 @@
wakeUp(locker);
}
-void RunLoop::schedule(const AbstractLocker&, RefPtr<TimerBase::ScheduledTask>&& task)
+void RunLoop::schedule(const AbstractLocker&, Ref<TimerBase::ScheduledTask>&& task)
{
m_schedules.append(WTFMove(task));
std::push_heap(m_schedules.begin(), m_schedules.end(), TimerBase::ScheduledTask::EarliestSchedule());
}
-void RunLoop::schedule(RefPtr<TimerBase::ScheduledTask>&& task)
+void RunLoop::schedule(Ref<TimerBase::ScheduledTask>&& task)
{
LockHolder locker(m_loopLock);
schedule(locker, WTFMove(task));
}
-void RunLoop::scheduleAndWakeUp(RefPtr<TimerBase::ScheduledTask> task)
+void RunLoop::scheduleAndWakeUp(Ref<TimerBase::ScheduledTask>&& task)
{
LockHolder locker(m_loopLock);
schedule(locker, WTFMove(task));
@@ -237,11 +237,11 @@
wakeUp(locker);
}
-void RunLoop::dispatchAfter(std::chrono::nanoseconds delay, Function<void ()>&& function)
+void RunLoop::dispatchAfter(Seconds delay, Function<void()>&& function)
{
LockHolder locker(m_loopLock);
bool repeating = false;
- schedule(locker, TimerBase::ScheduledTask::create(WTFMove(function), Seconds(delay.count() / 1000.0 / 1000.0 / 1000.0), repeating));
+ schedule(locker, TimerBase::ScheduledTask::create(WTFMove(function), delay, repeating));
wakeUp(locker);
}
@@ -269,7 +269,7 @@
m_scheduledTask = ScheduledTask::create([this] {
fired();
}, Seconds(interval), repeating);
- m_runLoop.scheduleAndWakeUp(m_scheduledTask);
+ m_runLoop.scheduleAndWakeUp(*m_scheduledTask);
}
void RunLoop::TimerBase::stop()
Modified: trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp (213857 => 213858)
--- trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/generic/WorkQueueGeneric.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -56,7 +56,7 @@
}
}
-void WorkQueue::dispatch(Function<void ()>&& function)
+void WorkQueue::dispatch(Function<void()>&& function)
{
RefPtr<WorkQueue> protect(this);
m_runLoop->dispatch([protect, function = WTFMove(function)] {
@@ -64,7 +64,7 @@
});
}
-void WorkQueue::dispatchAfter(std::chrono::nanoseconds delay, Function<void ()>&& function)
+void WorkQueue::dispatchAfter(Seconds delay, Function<void()>&& function)
{
RefPtr<WorkQueue> protect(this);
m_runLoop->dispatchAfter(delay, [protect, function = WTFMove(function)] {
Modified: trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp (213857 => 213858)
--- trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/glib/RunLoopGLib.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -124,7 +124,7 @@
class DispatchAfterContext {
WTF_MAKE_FAST_ALLOCATED;
public:
- DispatchAfterContext(Function<void ()>&& function)
+ DispatchAfterContext(Function<void()>&& function)
: m_function(WTFMove(function))
{
}
@@ -135,12 +135,12 @@
}
private:
- Function<void ()> m_function;
+ Function<void()> m_function;
};
-void RunLoop::dispatchAfter(std::chrono::nanoseconds duration, Function<void ()>&& function)
+void RunLoop::dispatchAfter(Seconds duration, Function<void()>&& function)
{
- GRefPtr<GSource> source = adoptGRef(g_timeout_source_new(std::chrono::duration_cast<std::chrono::milliseconds>(duration).count()));
+ GRefPtr<GSource> source = adoptGRef(g_timeout_source_new(duration.milliseconds()));
g_source_set_name(source.get(), "[WebKit] RunLoop dispatchAfter");
std::unique_ptr<DispatchAfterContext> context = std::make_unique<DispatchAfterContext>(WTFMove(function));
@@ -179,13 +179,13 @@
void RunLoop::TimerBase::updateReadyTime()
{
- if (!m_fireInterval.count()) {
+ if (!m_fireInterval) {
g_source_set_ready_time(m_source.get(), 0);
return;
}
gint64 currentTime = g_get_monotonic_time();
- gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, m_fireInterval.count());
+ gint64 targetTime = currentTime + std::min<gint64>(G_MAXINT64 - currentTime, m_fireInterval.microseconds());
ASSERT(targetTime >= currentTime);
g_source_set_ready_time(m_source.get(), targetTime);
}
@@ -192,12 +192,7 @@
void RunLoop::TimerBase::start(double fireInterval, bool repeat)
{
- auto intervalDuration = std::chrono::duration<double>(fireInterval);
- auto safeDuration = std::chrono::microseconds::max();
- if (intervalDuration < safeDuration)
- safeDuration = std::chrono::duration_cast<std::chrono::microseconds>(intervalDuration);
-
- m_fireInterval = safeDuration;
+ m_fireInterval = Seconds(fireInterval);
m_isRepeating = repeat;
updateReadyTime();
}
Modified: trunk/Source/WTF/wtf/win/WorkQueueWin.cpp (213857 => 213858)
--- trunk/Source/WTF/wtf/win/WorkQueueWin.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WTF/wtf/win/WorkQueueWin.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -51,7 +51,7 @@
m_functionQueueLock.lock();
while (!m_functionQueue.isEmpty()) {
- Vector<Function<void ()>> functionQueue;
+ Vector<Function<void()>> functionQueue;
m_functionQueue.swap(functionQueue);
// Allow more work to be scheduled while we're not using the queue directly.
@@ -98,7 +98,7 @@
::DeleteTimerQueueEx(m_timerQueue, 0);
}
-void WorkQueue::dispatch(Function<void ()>&& function)
+void WorkQueue::dispatch(Function<void()>&& function)
{
MutexLocker locker(m_functionQueueLock);
ref();
@@ -118,7 +118,7 @@
static RefPtr<TimerContext> create() { return adoptRef(new TimerContext); }
WorkQueue* queue;
- Function<void ()> function;
+ Function<void()> function;
Mutex timerMutex;
HANDLE timer;
@@ -149,7 +149,7 @@
}
}
-void WorkQueue::dispatchAfter(std::chrono::nanoseconds duration, Function<void ()>&& function)
+void WorkQueue::dispatchAfter(Seconds duration, Function<void()>&& function)
{
ASSERT(m_timerQueue);
ref();
@@ -164,7 +164,7 @@
// timer handle has been stored in it.
MutexLocker lock(context->timerMutex);
- int64_t milliseconds = std::chrono::duration_cast<std::chrono::milliseconds>(duration).count();
+ int64_t milliseconds = duration.milliseconds();
// From empirical testing, we've seen CreateTimerQueueTimer() sometimes fire up to 5+ ms early.
// This causes havoc for clients of this code that expect to not be called back until the
Modified: trunk/Source/WebKit2/ChangeLog (213857 => 213858)
--- trunk/Source/WebKit2/ChangeLog 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WebKit2/ChangeLog 2017-03-13 18:56:54 UTC (rev 213858)
@@ -1,3 +1,16 @@
+2017-03-13 Yusuke Suzuki <[email protected]>
+
+ [WTF] Clean up RunLoop and WorkQueue with Seconds and Function
+ https://bugs.webkit.org/show_bug.cgi?id=169537
+
+ Reviewed by Sam Weinig.
+
+ * Shared/ChildProcess.cpp:
+ (WebKit::didCloseOnConnectionWorkQueue):
+ * UIProcess/Storage/LocalStorageDatabase.cpp:
+ * WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp:
+ (WebKit::AcceleratedSurfaceX11::resize):
+
2017-03-13 Chris Dumez <[email protected]>
Allow termination of background WebProcesses that go over a given CPU usage threshold
Modified: trunk/Source/WebKit2/Shared/ChildProcess.cpp (213857 => 213858)
--- trunk/Source/WebKit2/Shared/ChildProcess.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WebKit2/Shared/ChildProcess.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -48,7 +48,7 @@
{
// If the connection has been closed and we haven't responded in the main thread for 10 seconds
// the process will exit forcibly.
- auto watchdogDelay = std::chrono::seconds(10);
+ auto watchdogDelay = 10_s;
WorkQueue::create("com.apple.WebKit.ChildProcess.WatchDogQueue")->dispatchAfter(watchdogDelay, [] {
// We use _exit here since the watchdog callback is called from another thread and we don't want
Modified: trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp (213857 => 213858)
--- trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WebKit2/UIProcess/Storage/LocalStorageDatabase.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -40,7 +40,7 @@
using namespace WebCore;
-static const auto databaseUpdateInterval = std::chrono::seconds(1);
+static const auto databaseUpdateInterval = 1_s;
static const int maximumItemsToUpdate = 100;
Modified: trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp (213857 => 213858)
--- trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Source/WebKit2/WebProcess/WebPage/gtk/AcceleratedSurfaceX11.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -144,7 +144,7 @@
XFlush(m_display);
// Release the previous pixmap later to give some time to the UI process to update.
- RunLoop::main().dispatchAfter(std::chrono::seconds(5), [pixmap = WTFMove(m_pixmap)] { });
+ RunLoop::main().dispatchAfter(5_s, [pixmap = WTFMove(m_pixmap)] { });
createPixmap();
return true;
}
Modified: trunk/Tools/ChangeLog (213857 => 213858)
--- trunk/Tools/ChangeLog 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Tools/ChangeLog 2017-03-13 18:56:54 UTC (rev 213858)
@@ -1,3 +1,13 @@
+2017-03-13 Yusuke Suzuki <[email protected]>
+
+ [WTF] Clean up RunLoop and WorkQueue with Seconds and Function
+ https://bugs.webkit.org/show_bug.cgi?id=169537
+
+ Reviewed by Sam Weinig.
+
+ * TestWebKitAPI/Tests/WTF/WorkQueue.cpp:
+ (TestWebKitAPI::TEST):
+
2017-03-13 Carlos Alberto Lopez Perez <[email protected]>
[GTK] Remove dead code from previous autotools build in build-jsc
Modified: trunk/Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp (213857 => 213858)
--- trunk/Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp 2017-03-13 18:09:30 UTC (rev 213857)
+++ trunk/Tools/TestWebKitAPI/Tests/WTF/WorkQueue.cpp 2017-03-13 18:56:54 UTC (rev 213858)
@@ -66,7 +66,7 @@
queue->dispatch([&](void) {
m_functionCallOrder.append(longTestLabel);
- std::this_thread::sleep_for(std::chrono::nanoseconds(100));
+ std::this_thread::sleep_for(100ns);
calledLongTest = true;
});
@@ -120,7 +120,7 @@
});
queue2->dispatch([&](void) {
- std::this_thread::sleep_for(std::chrono::milliseconds(50));
+ std::this_thread::sleep_for(50ms);
LockHolder locker(m_lock);
@@ -178,7 +178,7 @@
m_testCompleted.notifyOne();
});
- queue->dispatchAfter(std::chrono::milliseconds(500), [&](void) {
+ queue->dispatchAfter(500_ms, [&](void) {
LockHolder locker(m_lock);
m_functionCallOrder.append(dispatchAfterLabel);
calledDispatchAfterTest = true;
@@ -212,7 +212,7 @@
LockHolder locker(lock);
{
auto queue = WorkQueue::create("com.apple.WebKit.Test.dispatchAfter");
- queue->dispatchAfter(std::chrono::milliseconds(500), [&](void) {
+ queue->dispatchAfter(500_ms, [&](void) {
LockHolder locker(lock);
dispatchAfterTestStarted.wait(lock, [&] {
return started;