MRPT  2.0.1
internal_class_registry.h
Go to the documentation of this file.
1 /* +------------------------------------------------------------------------+
2  | Mobile Robot Programming Toolkit (MRPT) |
3  | https://www.mrpt.org/ |
4  | |
5  | Copyright (c) 2005-2020, Individual contributors, see AUTHORS file |
6  | See: https://www.mrpt.org/Authors - All rights reserved. |
7  | Released under BSD License. See: https://www.mrpt.org/License |
8  +------------------------------------------------------------------------+ */
9 #pragma once
10 
11 #include <atomic>
12 #include <mutex>
13 #include <queue>
14 
15 namespace mrpt::rtti
16 {
17 using TRegisterFunction = void (*)(); // A void(void) function
18 
20 {
21  std::queue<TRegisterFunction> funcs;
22  mutable std::mutex funcs_cs;
23 
24  /** Retrieve the next message in the queue, or nullptr if there is no
25  * message. The user MUST call "delete" with the returned object after use.
26  */
27  inline bool get(TRegisterFunction& ret)
28  {
29  std::lock_guard<std::mutex> lock(funcs_cs);
30  if (funcs.empty())
31  return false;
32  else
33  {
34  ret = funcs.front();
35  funcs.pop();
36  return true;
37  }
38  }
39 };
40 
41 // Use a queue for the pending register issues, but also an atomic counter,
42 // which is much faster to check than a CS.
43 std::atomic<int>& pending_class_registers_count();
44 queue_register_functions_t& pending_class_registers();
45 /** Set to true if pending_class_registers() has been called after
46  * registerAllPendingClasses(). Startup value is false. */
48 
49 } // namespace mrpt::rtti
std::queue< TRegisterFunction > funcs
bool pending_class_registers_modified
Set to true if pending_class_registers() has been called after registerAllPendingClasses().
std::atomic< int > & pending_class_registers_count()
void(*)() TRegisterFunction
queue_register_functions_t & pending_class_registers()



Page generated by Doxygen 1.8.14 for MRPT 2.0.1 Git: 0fef1a6d7 Fri Apr 3 23:00:21 2020 +0200 at vie abr 3 23:20:28 CEST 2020