diff options
author | Vincent Ambo <tazjin@google.com> | 2020-05-18T01·34+0100 |
---|---|---|
committer | Vincent Ambo <tazjin@google.com> | 2020-05-18T01·34+0100 |
commit | 6dc6c29fa4a4ddd3bb72f8415fac5936d719bd44 (patch) | |
tree | 560a8389d1682465599d94193053811acfd5de37 /third_party/nix/src/libutil/affinity.cc | |
parent | c584480cd46fb49e690e931f326472e512a82878 (diff) |
refactor(3p/nix/libutil): Replace internal logging library with glog r/754
Diffstat (limited to 'third_party/nix/src/libutil/affinity.cc')
-rw-r--r-- | third_party/nix/src/libutil/affinity.cc | 23 |
1 files changed, 16 insertions, 7 deletions
diff --git a/third_party/nix/src/libutil/affinity.cc b/third_party/nix/src/libutil/affinity.cc index faee4926d579..af3bc152f402 100644 --- a/third_party/nix/src/libutil/affinity.cc +++ b/third_party/nix/src/libutil/affinity.cc @@ -1,4 +1,5 @@ #include "affinity.hh" +#include <glog/logging.h> #include "types.hh" #include "util.hh" @@ -15,14 +16,18 @@ static cpu_set_t savedAffinity; void setAffinityTo(int cpu) { #if __linux__ - if (sched_getaffinity(0, sizeof(cpu_set_t), &savedAffinity) == -1) return; + if (sched_getaffinity(0, sizeof(cpu_set_t), &savedAffinity) == -1) { + return; + } + didSaveAffinity = true; - debug(format("locking this thread to CPU %1%") % cpu); + DLOG(INFO) << "locking this thread to CPU " << cpu; cpu_set_t newAffinity; CPU_ZERO(&newAffinity); CPU_SET(cpu, &newAffinity); - if (sched_setaffinity(0, sizeof(cpu_set_t), &newAffinity) == -1) - printError(format("failed to lock thread to CPU %1%") % cpu); + if (sched_setaffinity(0, sizeof(cpu_set_t), &newAffinity) == -1) { + LOG(ERROR) << "failed to lock thread to CPU " << cpu; + } #endif } @@ -38,9 +43,13 @@ int lockToCurrentCPU() { void restoreAffinity() { #if __linux__ - if (!didSaveAffinity) return; - if (sched_setaffinity(0, sizeof(cpu_set_t), &savedAffinity) == -1) - printError("failed to restore affinity %1%"); + if (!didSaveAffinity) { + return; + } + + if (sched_setaffinity(0, sizeof(cpu_set_t), &savedAffinity) == -1) { + LOG(ERROR) << "failed to restore affinity"; + } #endif } |