зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1495871 - use C++11 statics in time_win.cc; r=jld
C++11 provides guaranteed thread-safe static initialization, so we can use that instead of ipc's baroque Singleton class.
This commit is contained in:
Родитель
e2d2f91d22
Коммит
04abc48f2b
|
@ -47,7 +47,6 @@
|
|||
#include "base/basictypes.h"
|
||||
#include "base/lock.h"
|
||||
#include "base/logging.h"
|
||||
#include "base/singleton.h"
|
||||
#include "mozilla/Casting.h"
|
||||
|
||||
using base::Time;
|
||||
|
@ -249,6 +248,11 @@ class NowSingleton {
|
|||
return TimeDelta::FromMilliseconds(now) + rollover_;
|
||||
}
|
||||
|
||||
static NowSingleton& instance() {
|
||||
static NowSingleton now;
|
||||
return now;
|
||||
}
|
||||
|
||||
private:
|
||||
Lock lock_; // To protected last_seen_ and rollover_.
|
||||
TimeDelta rollover_; // Accumulation of time lost due to rollover.
|
||||
|
@ -269,5 +273,5 @@ TimeTicks::TickFunctionType TimeTicks::SetMockTickFunction(
|
|||
|
||||
// static
|
||||
TimeTicks TimeTicks::Now() {
|
||||
return TimeTicks() + Singleton<NowSingleton>::get()->Now();
|
||||
return TimeTicks() + NowSingleton::instance().Now();
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче