Skip to content

Commit

Permalink
Making use of GetSystemTimePreciseAsFileTime dynamic - code review fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
koldat committed Feb 2, 2016
1 parent 502d41f commit 57a95a7
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 14 deletions.
4 changes: 3 additions & 1 deletion db/auto_roll_logger.cc
Original file line number Diff line number Diff line change
Expand Up @@ -32,9 +32,11 @@ Status AutoRollLogger::ResetLogger() {
}

void AutoRollLogger::RollLogFile() {
// This function is called when log is rotating. Two rotations
// can happen quickly (NowMicro returns same value). To not overwrite
// previous log file we increment by one micro second and try again.
uint64_t now = env_->NowMicros();
std::string old_fname;
// Try to check target name only 10 times at most
for (int i = 0; i < 10; i++) {
old_fname = OldInfoLogFileName(
dbname_, now, db_absolute_path_, db_log_dir_);
Expand Down
20 changes: 7 additions & 13 deletions port/win/env_win.cc
Original file line number Diff line number Diff line change
Expand Up @@ -2110,28 +2110,22 @@ class WinEnv : public Env {
std::vector<ThreadPool> thread_pools_;
mutable std::mutex mu_;
std::vector<std::thread> threads_to_join_;
static FnGetSystemTimePreciseAsFileTime GetSystemTimePreciseAsFileTime_;
static bool GetSystemTimePreciseAsFileTimeInitialized_;
FnGetSystemTimePreciseAsFileTime GetSystemTimePreciseAsFileTime_;
};

FnGetSystemTimePreciseAsFileTime WinEnv::GetSystemTimePreciseAsFileTime_ = NULL;
bool WinEnv::GetSystemTimePreciseAsFileTimeInitialized_ = false;

WinEnv::WinEnv()
: checkedDiskForMmap_(false),
forceMmapOff(false),
page_size_(4 * 1012),
allocation_granularity_(page_size_),
perf_counter_frequency_(0),
thread_pools_(Priority::TOTAL) {
thread_pools_(Priority::TOTAL),
GetSystemTimePreciseAsFileTime_(NULL) {

if (!GetSystemTimePreciseAsFileTimeInitialized_) {
HMODULE module = GetModuleHandle("kernel32.dll");
if (module != NULL) {
GetSystemTimePreciseAsFileTime_ = (FnGetSystemTimePreciseAsFileTime)GetProcAddress(
module, "GetSystemTimePreciseAsFileTime");
}
GetSystemTimePreciseAsFileTimeInitialized_ = true;
HMODULE module = GetModuleHandle("kernel32.dll");
if (module != NULL) {
GetSystemTimePreciseAsFileTime_ = (FnGetSystemTimePreciseAsFileTime)GetProcAddress(
module, "GetSystemTimePreciseAsFileTime");
}

SYSTEM_INFO sinfo;
Expand Down

0 comments on commit 57a95a7

Please sign in to comment.