Remove some unnecessary uses of LOG(FATAL) in folly
authorJordan DeLong <jdelong@fb.com>
Fri, 11 Jan 2013 20:52:50 +0000 (12:52 -0800)
committerJordan DeLong <jdelong@fb.com>
Sat, 19 Jan 2013 00:37:56 +0000 (16:37 -0800)
Summary:
ScopeGuard::execute will already call std::terminate if an
exception is thrown, as it's noexcept, and the case in
ConcurrentSkipList should be a check.

Test Plan:
Ran folly tests.  Will look at phabricator to see if
anything breaks downstream from removing glog/logging.h from
scopeguard.

Reviewed By: chip@fb.com

FB internal diff: D677038

folly/ConcurrentSkipList.h
folly/ScopeGuard.h
folly/test/ScopeGuardTest.cpp

index b3a6be251af01947ad57e1ef0bffd846ed5c05dd..6c2a50064a8cce069565c95839a209dc8dbbf7fa 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2013 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -182,9 +182,7 @@ class ConcurrentSkipList {
   //===================================================================
 
   ~ConcurrentSkipList() {
-    LOG_IF(FATAL, recycler_.refs() > 0)
-      << "number of accessors is not 0, " << recycler_.refs() << " instead!"
-      << " This shouldn't have happened!";
+    CHECK_EQ(recycler_.refs(), 0);
     while (NodeType* current = head_.load(std::memory_order_relaxed)) {
       NodeType* tmp = current->skip(0);
       NodeType::destroy(current);
index 5647675fd1b370e55776b2e163737067ce7eddb2..f6f2e2c3afef12079fe0fdb7c91f37077ed841c8 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2013 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -20,7 +20,6 @@
 #include <cstddef>
 #include <functional>
 #include <new>
-#include <glog/logging.h>
 
 #include "folly/Preprocessor.h"
 
@@ -108,16 +107,7 @@ class ScopeGuardImpl : public ScopeGuardImplBase {
 private:
   void* operator new(size_t) = delete;
 
-  void execute() noexcept {
-    try {
-      function_();
-    } catch (const std::exception& ex) {
-      LOG(FATAL) << "ScopeGuard cleanup function threw a " <<
-        typeid(ex).name() << "exception: " << ex.what();
-    } catch (...) {
-      LOG(FATAL) << "ScopeGuard cleanup function threw a non-exception object";
-    }
-  }
+  void execute() noexcept { function_(); }
 
   FunctionType function_;
 };
index b84f18ce6c41cf39acf883662632447ee2dd7abf..35b1e3a905e8328f86b75935b8a947dadd6d1752 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2012 Facebook, Inc.
+ * Copyright 2013 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -18,6 +18,7 @@
 
 #include <gflags/gflags.h>
 #include <gtest/gtest.h>
+#include <glog/logging.h>
 
 #include <functional>
 #include <stdexcept>