DCCL v4
thread_safety.h
1 // Copyright 2012-2023:
2 // GobySoft, LLC (2013-)
3 // Massachusetts Institute of Technology (2007-2014)
4 // Community contributors (see AUTHORS file)
5 // File authors:
6 // Toby Schneider <toby@gobysoft.org>
7 //
8 //
9 // This file is part of the Dynamic Compact Control Language Library
10 // ("DCCL").
11 //
12 // DCCL is free software: you can redistribute it and/or modify
13 // it under the terms of the GNU Lesser General Public License as published by
14 // the Free Software Foundation, either version 2.1 of the License, or
15 // (at your option) any later version.
16 //
17 // DCCL is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU Lesser General Public License for more details.
21 //
22 // You should have received a copy of the GNU Lesser General Public License
23 // along with DCCL. If not, see <http://www.gnu.org/licenses/>.
24 #include "dccl/def.h"
25 
26 #if DCCL_THREAD_SUPPORT
27 #include <atomic>
28 #include <mutex>
29 #include <thread>
30 namespace dccl
31 {
32 extern std::recursive_mutex g_dynamic_protobuf_manager_mutex;
33 extern std::recursive_mutex g_dlog_mutex;
34 } // namespace dccl
35 
36 #define DCCL_LOCK_DYNAMIC_PROTOBUF_MANAGER_MUTEX \
37  std::lock_guard<std::recursive_mutex> l(dccl::g_dynamic_protobuf_manager_mutex);
38 #define DCCL_LOCK_DLOG_MUTEX std::lock_guard<std::recursive_mutex> l(dccl::g_dlog_mutex);
39 #else
40 // no op
41 #define DCCL_LOCK_DYNAMIC_PROTOBUF_MANAGER_MUTEX
42 #define DCCL_LOCK_DLOG_MUTEX
43 #endif
dccl
Dynamic Compact Control Language namespace.
Definition: any.h:46