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