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::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 }
50 
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
typedef void(APIENTRYP PFNGLBLENDCOLORPROC)(GLclampf red
queue_register_functions_t & pending_class_registers()



Page generated by Doxygen 1.8.14 for MRPT 1.9.9 Git: 7d5e6d718 Fri Aug 24 01:51:28 2018 +0200 at lun nov 2 08:35:50 CET 2020