RSB
0.7.0
|
Instances of this class maintain a pool of ongoing Assembly s. More...
#include <Assembly.h>
Classes | |
class | PruningTask |
Public Member Functions | |
AssemblyPool (const unsigned int &ageS=20, const unsigned int &pruningIntervalMs=4000) | |
Creates a new pool with specified settings. | |
~AssemblyPool () | |
bool | isPruning () const |
Tells whether the pool is currently pruning fragments or not. | |
void | setPruning (const bool &prune) |
Changes the pruning settings (enables or disables pruning) and waits until the new settings are applied. | |
rsb::protocol::NotificationPtr | add (rsb::protocol::FragmentedNotificationPtr notification) |
Adds a new notification to the pool and tries to join it with already pooled parts. |
Private Types | |
typedef std::map< std::string, boost::shared_ptr< Assembly > > | Pool |
Private Attributes | |
rsc::logging::LoggerPtr | logger |
Pool | pool |
boost::recursive_mutex | poolMutex |
const unsigned int | pruningAgeS |
const unsigned int | pruningIntervalMs |
rsc::threading::ThreadedTaskExecutor | executor |
boost::recursive_mutex | pruningMutex |
rsc::threading::TaskPtr | pruningTask |
Instances of this class maintain a pool of ongoing Assembly s.
In addition to adding arriving notification fragments to these, the ages of assemblies are monitor and old assemblies are pruned.
Definition at line 105 of file Assembly.h.
|
private |
Definition at line 156 of file Assembly.h.
|
explicit |
Creates a new pool with specified settings.
Pruning will not immediately start with these settings. It has to be enabled explicitly using the appropriate method calls.
ageS | defines the max. allowed age of pooled fragments before they are pruned (s) > 0 |
pruningIntervalMs | the interval to use for checking the age (ms) > 0 |
std::domain_error | 0 given for ageMs or pruningIntervalMs |
Definition at line 130 of file Assembly.cpp.
rsb::spread::AssemblyPool::~AssemblyPool | ( | ) |
Definition at line 142 of file Assembly.cpp.
References setPruning().
rsb::protocol::NotificationPtr rsb::spread::AssemblyPool::add | ( | rsb::protocol::FragmentedNotificationPtr | notification | ) |
Adds a new notification to the pool and tries to join it with already pooled parts.
If a complete event notification is available after this message, the joined Notification is returned and the all parts are removed from the pool.
notification | notification to add to the pool |
protocol::ProtocolException | if a fragment was received multiple times |
Definition at line 170 of file Assembly.cpp.
bool rsb::spread::AssemblyPool::isPruning | ( | ) | const |
Tells whether the pool is currently pruning fragments or not.
This method is thread-safe.
true
if the pool is currently pruning, else false
Definition at line 146 of file Assembly.cpp.
References pruningMutex, and pruningTask.
Referenced by setPruning().
void rsb::spread::AssemblyPool::setPruning | ( | const bool & | prune | ) |
Changes the pruning settings (enables or disables pruning) and waits until the new settings are applied.
This method is thread-safe.
prune | if true , start pruning if it is not yet running, if false , disable pruning if active |
Definition at line 151 of file Assembly.cpp.
References executor, isPruning(), logger, pool, poolMutex, pruningAgeS, pruningIntervalMs, pruningMutex, and pruningTask.
Referenced by ~AssemblyPool().
|
private |
Definition at line 181 of file Assembly.h.
Referenced by setPruning().
|
private |
Definition at line 174 of file Assembly.h.
Referenced by add(), rsb::spread::AssemblyPool::PruningTask::execute(), and setPruning().
|
private |
Definition at line 175 of file Assembly.h.
Referenced by add(), rsb::spread::AssemblyPool::PruningTask::execute(), and setPruning().
|
private |
Definition at line 176 of file Assembly.h.
Referenced by add(), rsb::spread::AssemblyPool::PruningTask::execute(), and setPruning().
|
private |
Definition at line 178 of file Assembly.h.
Referenced by setPruning().
|
private |
Definition at line 179 of file Assembly.h.
Referenced by setPruning().
|
mutableprivate |
Definition at line 182 of file Assembly.h.
Referenced by isPruning(), and setPruning().
|
private |
Definition at line 183 of file Assembly.h.
Referenced by isPruning(), and setPruning().