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

Let StaticMeta have a deleted dtor

Summary: [Folly] Let `StaticMeta` have a deleted dtor - a compile-time enforcement that the dtor will not be invoked, to replace the existing runtime non-enforcement.

Reviewed By: elsteveogrande

Differential Revision: D9624686

fbshipit-source-id: 9185defbea343e4123e66c8d0d38f20c561aebea
parent 8f91fe9e
...@@ -342,10 +342,6 @@ struct StaticMetaBase { ...@@ -342,10 +342,6 @@ struct StaticMetaBase {
StaticMetaBase(ThreadEntry* (*threadEntry)(), bool strict); StaticMetaBase(ThreadEntry* (*threadEntry)(), bool strict);
[[noreturn]] ~StaticMetaBase() {
folly::assume_unreachable();
}
void push_back(ThreadEntry* t) { void push_back(ThreadEntry* t) {
t->next = &head_; t->next = &head_;
t->prev = head_.prev; t->prev = head_.prev;
...@@ -403,6 +399,9 @@ struct StaticMetaBase { ...@@ -403,6 +399,9 @@ struct StaticMetaBase {
ThreadEntry head_; ThreadEntry head_;
ThreadEntry* (*threadEntry_)(); ThreadEntry* (*threadEntry_)();
bool strict_; bool strict_;
protected:
~StaticMetaBase() {}
}; };
// Held in a singleton to track our global instances. // Held in a singleton to track our global instances.
...@@ -413,7 +412,7 @@ struct StaticMetaBase { ...@@ -413,7 +412,7 @@ struct StaticMetaBase {
// for threads that use ThreadLocalPtr objects collide on a lock inside // for threads that use ThreadLocalPtr objects collide on a lock inside
// StaticMeta; you can specify multiple Tag types to break that lock. // StaticMeta; you can specify multiple Tag types to break that lock.
template <class Tag, class AccessMode> template <class Tag, class AccessMode>
struct StaticMeta : StaticMetaBase { struct StaticMeta final : StaticMetaBase {
StaticMeta() StaticMeta()
: StaticMetaBase( : StaticMetaBase(
&StaticMeta::getThreadEntrySlow, &StaticMeta::getThreadEntrySlow,
...@@ -425,6 +424,8 @@ struct StaticMeta : StaticMetaBase { ...@@ -425,6 +424,8 @@ struct StaticMeta : StaticMetaBase {
/*child*/ &StaticMeta::onForkChild); /*child*/ &StaticMeta::onForkChild);
} }
~StaticMeta() = delete;
static StaticMeta<Tag, AccessMode>& instance() { static StaticMeta<Tag, AccessMode>& instance() {
// Leak it on exit, there's only one per process and we don't have to // Leak it on exit, there's only one per process and we don't have to
// worry about synchronization with exiting threads. // worry about synchronization with exiting threads.
......
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