Commit c84a82a6 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Let SingletonThreadLocal no longer depend on Singleton

Summary:
[Folly] Let `SingletonThreadLocal` no longer depend on `Singleton`.

After recent changes, the dependency was only for `DefaultTag` and `DefaultMake`, not for `Singleton` or `LeakySingleton` itself. So extract the two small types to a small detail header, and split.

Reviewed By: ot

Differential Revision: D7300727

fbshipit-source-id: 5ccfc0abff7dbb8c2c9ea83fb9bb3a085904ce58
parent 7f696fbd
......@@ -125,6 +125,7 @@
#include <folly/Executor.h>
#include <folly/Memory.h>
#include <folly/Synchronized.h>
#include <folly/detail/Singleton.h>
#include <folly/detail/StaticSingletonManager.h>
#include <folly/experimental/ReadMostlySharedPtr.h>
#include <folly/hash/Hash.h>
......@@ -180,17 +181,6 @@ class SingletonVault;
namespace detail {
struct DefaultTag {};
template <typename T>
struct DefaultMake {
// Required form until C++17, which permits returning objects of types which
// are neither copy-constructible nor move-constructible.
T* operator()(unsigned char (&buf)[sizeof(T)]) const {
return new (buf) T();
}
};
// A TypeDescriptor is the unique handle for a given singleton. It is
// a combinaiton of the type and of the optional name, and is used as
// a key in unordered_maps.
......
......@@ -16,8 +16,8 @@
#pragma once
#include <folly/Singleton.h>
#include <folly/ThreadLocal.h>
#include <folly/detail/Singleton.h>
#include <folly/functional/Invoke.h>
namespace folly {
......
/*
* Copyright 2018-present 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.
*/
#pragma once
namespace folly {
namespace detail {
struct DefaultTag {};
template <typename T>
struct DefaultMake {
// Required form until C++17, which permits returning objects of types which
// are neither copy-constructible nor move-constructible.
T* operator()(unsigned char (&buf)[sizeof(T)]) const {
return new (buf) T();
}
};
} // namespace detail
} // namespace folly
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment