Fix folly/test:singleton_test - Singleton.SharedPtrUsage
[folly.git] / folly / test / SingletonVaultCTest.cpp
index 1182278e1e28138b34e70acd3e1c1cc80e829991..7d48b88ca862b47286e0de07d81532eba434f2c5 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2015 Facebook, Inc.
+ * Copyright 2017 Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
 #include <folly/Singleton.h>
 #include <folly/SingletonVault_c.h>
 
-#include <gtest/gtest.h>
+#include <folly/portability/GTest.h>
 
-#include <thread>
-
-__thread long instance_counter_instances = 0;
+FOLLY_TLS long instance_counter_instances = 0;
 
 class InstanceCounter {
  public:
@@ -48,7 +46,7 @@ TEST(SingletonVault, singletonsAreCreatedAndDestroyed) {
   auto vault = folly::SingletonVault::singleton<TestTag>();
   SingletonTest<InstanceCounter> counter_singleton;
   SingletonVault_registrationComplete((SingletonVault_t*) vault);
-  InstanceCounter *counter = SingletonTest<InstanceCounter>::get();
+  SingletonTest<InstanceCounter>::try_get();
   EXPECT_EQ(instance_counter_instances, 1);
   SingletonVault_destroyInstances((SingletonVault_t*) vault);
   EXPECT_EQ(instance_counter_instances, 0);