Add folly::Expected, an alternative to exceptions for non-throwing APIs that can...
[folly.git] / folly / ThreadCachedInt.h
index 6a6a694809f4efad2ec2efb6de32d78f484bec7a..fcc4a7ea0e2f18e256f7c79db215d170a5e2a1de 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2014 Facebook, Inc.
+ * Copyright 2016 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  * @author Spencer Ahrens (sahrens)
  */
 
-#ifndef FOLLY_THREADCACHEDINT_H
-#define FOLLY_THREADCACHEDINT_H
+#pragma once
 
 #include <atomic>
 
 #include <boost/noncopyable.hpp>
 
-#include "folly/Likely.h"
-#include "folly/ThreadLocal.h"
+#include <folly/Likely.h>
+#include <folly/ThreadLocal.h>
 
 namespace folly {
 
@@ -48,7 +47,7 @@ class ThreadCachedInt : boost::noncopyable {
 
   void increment(IntT inc) {
     auto cache = cache_.get();
-    if (UNLIKELY(cache == NULL || cache->parent_ == NULL)) {
+    if (UNLIKELY(cache == nullptr || cache->parent_ == nullptr)) {
       cache = new IntCache(*this);
       cache_.reset(cache);
     }
@@ -122,7 +121,7 @@ class ThreadCachedInt : boost::noncopyable {
   // need to make sure we signal that this parent is dead.
   ~ThreadCachedInt() {
     for (auto& cache : cache_.accessAllThreads()) {
-      cache.parent_ = NULL;
+      cache.parent_ = nullptr;
     }
   }
 
@@ -175,5 +174,3 @@ class ThreadCachedInt : boost::noncopyable {
 };
 
 }
-
-#endif