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



Page generated by Doxygen 1.8.17 for MRPT 1.9.9 Git: ad3a9d8ae Tue May 1 23:10:22 2018 -0700 at miƩ 12 jul 2023 10:03:34 CEST