40 static AtForkList& instance() {
41 static auto instance =
new AtForkList();
46 instance().tasksLock.lock();
48 auto&
tasks = instance().tasks;
49 auto task =
tasks.rbegin();
50 for (; task !=
tasks.rend(); ++task) {
51 if (!task->prepare()) {
55 if (task ==
tasks.rend()) {
58 for (
auto untask =
tasks.rbegin(); untask != task; ++untask) {
65 auto&
tasks = instance().tasks;
66 for (
auto& task :
tasks) {
69 instance().tasksLock.unlock();
73 auto&
tasks = instance().tasks;
74 for (
auto& task :
tasks) {
77 instance().tasksLock.unlock();
85 #if FOLLY_HAVE_PTHREAD_ATFORK 86 int ret = pthread_atfork(
89 throw_exception<std::system_error>(
90 ret, std::generic_category(),
"pthread_atfork failed");
92 #elif !__ANDROID__ && !defined(_MSC_VER) 98 #warning pthread_atfork unavailable 105 AtForkList::instance();
113 std::lock_guard<std::mutex> lg(AtForkList::instance().
tasksLock);
114 AtForkList::instance().tasks.push_back(
119 auto&
list = AtForkList::instance();
120 std::lock_guard<std::mutex> lg(
list.tasksLock);
121 for (
auto it =
list.tasks.begin(); it !=
list.tasks.end(); ++it) {
122 if (it->object ==
object) {
123 list.tasks.erase(it);
constexpr detail::Map< Move > move
std::list< AtForkTask > tasks
—— Concurrent Priority Queue Implementation ——
requires E e noexcept(noexcept(s.error(std::move(e))))
Encoder::MutableCompressedList list
folly::Function< bool()> prepare
folly::Function< void()> child
static void unregisterHandler(void *object)
static void registerHandler(void *object, folly::Function< bool()> prepare, folly::Function< void()> parent, folly::Function< void()> child)
folly::Function< void()> parent