From 661c75b6e80e470548de41c4ab4a289a8d0711a8 Mon Sep 17 00:00:00 2001 From: Yedidya Feldblum Date: Mon, 1 Jan 2018 19:08:45 -0800 Subject: [PATCH] Remove SingletonVault C bindings Summary: [Folly] Remove `SingletonVault` C bindings. They are not generally needed. Reviewed By: spalamarchuk Differential Revision: D6632104 fbshipit-source-id: 3aecb35277bc76a2171487404d6994a5ea296afc --- folly/SingletonVault_c.cpp | 38 --------------------- folly/SingletonVault_c.h | 37 --------------------- folly/test/SingletonVaultCTest.cpp | 53 ------------------------------ 3 files changed, 128 deletions(-) delete mode 100644 folly/SingletonVault_c.cpp delete mode 100644 folly/SingletonVault_c.h delete mode 100644 folly/test/SingletonVaultCTest.cpp diff --git a/folly/SingletonVault_c.cpp b/folly/SingletonVault_c.cpp deleted file mode 100644 index f14173b6..00000000 --- a/folly/SingletonVault_c.cpp +++ /dev/null @@ -1,38 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -extern "C" { - -SingletonVault_t *SingletonVault_singleton() { - return folly::SingletonVault::singleton(); -} - -void SingletonVault_registrationComplete(SingletonVault_t *vault) { - ((folly::SingletonVault*) vault)->registrationComplete(); -} - -void SingletonVault_destroyInstances(SingletonVault_t *vault) { - ((folly::SingletonVault*) vault)->destroyInstances(); -} - -void SingletonVault_reenableInstances(SingletonVault_t *vault) { - ((folly::SingletonVault*) vault)->reenableInstances(); -} - -} // extern "C" diff --git a/folly/SingletonVault_c.h b/folly/SingletonVault_c.h deleted file mode 100644 index eb67192d..00000000 --- a/folly/SingletonVault_c.h +++ /dev/null @@ -1,37 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -// Plain C interface to SingletonVault. This facilitates combining programs -// that cannot use C++ (e.g. programs written in C) with libraries that use -// Singleton, by allowing the program to perform the required SingletonVault -// lifecycle calls. - -#pragma once - -#ifdef __cplusplus -extern "C" { -#endif - -typedef void SingletonVault_t; - -SingletonVault_t *SingletonVault_singleton(); -void SingletonVault_registrationComplete(SingletonVault_t *vault); -void SingletonVault_destroyInstances(SingletonVault_t *vault); -void SingletonVault_reenableInstances(SingletonVault_t *vault); - -#ifdef __cplusplus -} // extern "C" -#endif diff --git a/folly/test/SingletonVaultCTest.cpp b/folly/test/SingletonVaultCTest.cpp deleted file mode 100644 index 7d48b88c..00000000 --- a/folly/test/SingletonVaultCTest.cpp +++ /dev/null @@ -1,53 +0,0 @@ -/* - * 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. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -#include -#include - -#include - -FOLLY_TLS long instance_counter_instances = 0; - -class InstanceCounter { - public: - InstanceCounter() { - instance_counter_instances++; - } - - ~InstanceCounter() { - instance_counter_instances--; - } -}; - -TEST(SingletonVault, singletonReturnsSingletonInstance) { - SingletonVault_t *c = SingletonVault_singleton(); - auto *cpp = folly::SingletonVault::singleton(); - EXPECT_EQ(c, cpp); -} - -struct TestTag {}; -template -using SingletonTest = folly::Singleton ; - -TEST(SingletonVault, singletonsAreCreatedAndDestroyed) { - auto vault = folly::SingletonVault::singleton(); - SingletonTest counter_singleton; - SingletonVault_registrationComplete((SingletonVault_t*) vault); - SingletonTest::try_get(); - EXPECT_EQ(instance_counter_instances, 1); - SingletonVault_destroyInstances((SingletonVault_t*) vault); - EXPECT_EQ(instance_counter_instances, 0); -} -- 2.34.1