Ignore:
Timestamp:
Apr 11, 2017, 2:34:36 AM (8 years ago)
Author:
Yusuke Suzuki
Message:

[JSC] Enable JSRunLoopTimer for JSCOnly and Windows
https://bugs.webkit.org/show_bug.cgi?id=170655

Reviewed by Carlos Garcia Campos.

Source/JavaScriptCore:

  • runtime/JSRunLoopTimer.cpp:

(JSC::JSRunLoopTimer::JSRunLoopTimer):
(JSC::JSRunLoopTimer::scheduleTimer):
(JSC::JSRunLoopTimer::cancelTimer):

  • runtime/JSRunLoopTimer.h:

Source/WTF:

This patch makes RunLoop::Timer in Generic and Windows thread-safe to use it
in JSC's JSRunLoopTimer. Eventually, we would like to replace JSRunLoopTimer's
platform-dependent implementation to WTF::RunLoop::Timer.

  • wtf/RunLoop.h:
  • wtf/cf/RunLoopCF.cpp:

(WTF::RunLoop::TimerBase::start):

  • wtf/generic/RunLoopGeneric.cpp:

(WTF::RunLoop::TimerBase::ScheduledTask::EarliestSchedule::operator()):
(WTF::RunLoop::populateTasks):
(WTF::RunLoop::runImpl):
(WTF::RunLoop::schedule):
(WTF::RunLoop::scheduleAndWakeUp):
(WTF::RunLoop::TimerBase::~TimerBase):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::stop):
(WTF::RunLoop::TimerBase::isActive):

  • wtf/glib/RunLoopGLib.cpp:

(WTF::RunLoop::TimerBase::TimerBase):

  • wtf/win/RunLoopWin.cpp:

(WTF::RunLoop::TimerBase::timerFired):
(WTF::RunLoop::TimerBase::start):
(WTF::RunLoop::TimerBase::stop):
(WTF::RunLoop::TimerBase::isActive):

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/JavaScriptCore/runtime/JSRunLoopTimer.cpp

    r215088 r215223  
    162162    m_isScheduled = false;
    163163}
     164
    164165#else
     166
     167const Seconds JSRunLoopTimer::s_decade { 60 * 60 * 24 * 365 * 10 };
     168
    165169JSRunLoopTimer::JSRunLoopTimer(VM* vm)
    166170    : m_vm(vm)
     171    , m_apiLock(&vm->apiLock())
     172    , m_timer(RunLoop::current(), this, &JSRunLoopTimer::timerDidFire)
    167173{
     174    m_timer.startOneShot(s_decade);
    168175}
    169176
     
    172179}
    173180
    174 void JSRunLoopTimer::scheduleTimer(double)
     181void JSRunLoopTimer::scheduleTimer(double intervalInSeconds)
    175182{
     183    m_timer.startOneShot(intervalInSeconds);
     184    m_isScheduled = true;
    176185}
    177186
    178187void JSRunLoopTimer::cancelTimer()
    179188{
     189    m_timer.startOneShot(s_decade);
     190    m_isScheduled = false;
    180191}
     192
    181193#endif
    182    
     194
    183195} // namespace JSC
Note: See TracChangeset for help on using the changeset viewer.