MRPT
2.0.3
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
19
struct
queue_register_functions_t
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. */
47
extern
bool
pending_class_registers_modified
;
48
49
}
// namespace mrpt::rtti
mrpt::rtti::queue_register_functions_t::funcs_cs
std::mutex funcs_cs
Definition:
internal_class_registry.h:22
mrpt::rtti::queue_register_functions_t::funcs
std::queue< TRegisterFunction > funcs
Definition:
internal_class_registry.h:21
mrpt::rtti::TRegisterFunction
void(*)() TRegisterFunction
Definition:
internal_class_registry.h:17
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:27
mrpt::rtti::queue_register_functions_t
Definition:
internal_class_registry.h:19
mrpt::rtti
Definition:
CListOfClasses.h:15
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 2.0.3 at Thu May 21 21:53:32 UTC 2020