[EFL][WK2] Use nanoseconds in TimerWorkItem class consistently

https://bugs.webkit.org/show_bug.cgi?id=127263

Reviewed by Gyuyoung Kim.

After r162276 and r162300, TimerWorkItem is getting nanoseconds as parameter.
So it would be better to use nanoseconds in TimerWorkItem for consistency.

* Platform/efl/DispatchQueueEfl.cpp:
(DispatchQueue::performTimerWork):
(DispatchQueue::insertTimerWorkItem):
(DispatchQueue::getNextTimeOut):
* Platform/efl/DispatchQueueWorkItemEfl.h:
(TimerWorkItem::create):
(TimerWorkItem::expirationTimeNanoSeconds):
(TimerWorkItem::hasExpired):
(TimerWorkItem::TimerWorkItem):


git-svn-id: http://svn.webkit.org/repository/webkit/trunk@162490 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 5be92614
2014-01-21 Jinwoo Song <jinwoo7.song@samsung.com>
[EFL][WK2] Use nanoseconds in TimerWorkItem class consistently
https://bugs.webkit.org/show_bug.cgi?id=127263
Reviewed by Gyuyoung Kim.
After r162276 and r162300, TimerWorkItem is getting nanoseconds as parameter.
So it would be better to use nanoseconds in TimerWorkItem for consistency.
* Platform/efl/DispatchQueueEfl.cpp:
(DispatchQueue::performTimerWork):
(DispatchQueue::insertTimerWorkItem):
(DispatchQueue::getNextTimeOut):
* Platform/efl/DispatchQueueWorkItemEfl.h:
(TimerWorkItem::create):
(TimerWorkItem::expirationTimeNanoSeconds):
(TimerWorkItem::hasExpired):
(TimerWorkItem::TimerWorkItem):
2014-01-21 Tim Horton <timothy_horton@apple.com>
Don't copy ViewGestureGeometryCollector.messages.in into the WebProcess bundle.
......
......@@ -33,6 +33,7 @@
#include <wtf/Threading.h>
static const int microSecondsPerSecond = 1000000;
static const int nanoSecondsPerSecond = 1000000000;
static const int invalidSocketDescriptor = -1;
static const char wakeUpThreadMessage = 'W';
......@@ -170,10 +171,10 @@ void DispatchQueue::performTimerWork()
m_timerWorkItems.swap(timerWorkItems);
}
double currentTimeSeconds = monotonicallyIncreasingTime();
double currentTimeNanoSeconds = monotonicallyIncreasingTime() * nanoSecondsPerSecond;
for (size_t i = 0; i < timerWorkItems.size(); ++i) {
if (!timerWorkItems[i]->hasExpired(currentTimeSeconds)) {
if (!timerWorkItems[i]->hasExpired(currentTimeNanoSeconds)) {
insertTimerWorkItem(std::move(timerWorkItems[i]));
continue;
}
......@@ -210,7 +211,7 @@ void DispatchQueue::insertTimerWorkItem(std::unique_ptr<TimerWorkItem> item)
MutexLocker locker(m_timerWorkItemsLock);
// The items should be ordered by expire time.
for (; position < m_timerWorkItems.size(); ++position)
if (item->expirationTimeSeconds() < m_timerWorkItems[position]->expirationTimeSeconds())
if (item->expirationTimeNanoSeconds() < m_timerWorkItems[position]->expirationTimeNanoSeconds())
break;
m_timerWorkItems.insert(position, std::move(item));
......@@ -241,10 +242,10 @@ timeval* DispatchQueue::getNextTimeOut() const
static timeval timeValue;
timeValue.tv_sec = 0;
timeValue.tv_usec = 0;
double timeOut = m_timerWorkItems[0]->expirationTimeSeconds() - monotonicallyIncreasingTime();
if (timeOut > 0) {
timeValue.tv_sec = static_cast<long>(timeOut);
timeValue.tv_usec = static_cast<long>((timeOut - timeValue.tv_sec) * microSecondsPerSecond);
double timeOutSeconds = (m_timerWorkItems[0]->expirationTimeNanoSeconds() - monotonicallyIncreasingTime() * nanoSecondsPerSecond) / nanoSecondsPerSecond;
if (timeOutSeconds > 0) {
timeValue.tv_sec = static_cast<long>(timeOutSeconds);
timeValue.tv_usec = static_cast<long>((timeOutSeconds - timeValue.tv_sec) * microSecondsPerSecond);
}
return &timeValue;
......
......@@ -54,23 +54,23 @@ private:
class TimerWorkItem : public WorkItem {
public:
static std::unique_ptr<TimerWorkItem> create(PassRefPtr<WorkQueue> workQueue, std::function<void ()> function, std::chrono::nanoseconds delay)
static std::unique_ptr<TimerWorkItem> create(PassRefPtr<WorkQueue> workQueue, std::function<void ()> function, std::chrono::nanoseconds delayNanoSeconds)
{
ASSERT(delay.count() >= 0);
return std::unique_ptr<TimerWorkItem>(new TimerWorkItem(workQueue, std::move(function), monotonicallyIncreasingTime() + delay.count() / 1000000000ULL));
ASSERT(delayNanoSeconds.count() >= 0);
return std::unique_ptr<TimerWorkItem>(new TimerWorkItem(workQueue, std::move(function), monotonicallyIncreasingTime() * 1000000000.0 + delayNanoSeconds.count()));
}
double expirationTimeSeconds() const { return m_expirationTimeSeconds; }
bool hasExpired(double currentTimeSeconds) const { return currentTimeSeconds >= m_expirationTimeSeconds; }
double expirationTimeNanoSeconds() const { return m_expirationTimeNanoSeconds; }
bool hasExpired(double currentTimeNanoSeconds) const { return currentTimeNanoSeconds >= m_expirationTimeNanoSeconds; }
protected:
TimerWorkItem(PassRefPtr<WorkQueue> workQueue, std::function<void ()> function, double expirationTimeSeconds)
TimerWorkItem(PassRefPtr<WorkQueue> workQueue, std::function<void ()> function, double expirationTimeNanoSeconds)
: WorkItem(workQueue, std::move(function))
, m_expirationTimeSeconds(expirationTimeSeconds)
, m_expirationTimeNanoSeconds(expirationTimeNanoSeconds)
{
}
private:
double m_expirationTimeSeconds;
double m_expirationTimeNanoSeconds;
};
#endif // DispatchQueueWorkItemEfl_h
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment