RSB  0.7.0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
rsb::spread::AssemblyPool Class Reference

Instances of this class maintain a pool of ongoing Assembly s. More...

#include <Assembly.h>

Collaboration diagram for rsb::spread::AssemblyPool:
Collaboration graph

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

Detailed Description

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.

Author
jmoringe

Definition at line 105 of file Assembly.h.

Member Typedef Documentation

typedef std::map<std::string, boost::shared_ptr<Assembly> > rsb::spread::AssemblyPool::Pool
private

Definition at line 156 of file Assembly.h.

Constructor & Destructor Documentation

rsb::spread::AssemblyPool::AssemblyPool ( const unsigned int &  ageS = 20,
const unsigned int &  pruningIntervalMs = 4000 
)
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.

Parameters
ageSdefines the max. allowed age of pooled fragments before they are pruned (s) > 0
pruningIntervalMsthe interval to use for checking the age (ms) > 0
Exceptions
std::domain_error0 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().

Here is the call graph for this function:

Member Function Documentation

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.

Parameters
notificationnotification to add to the pool
Returns
if a joined message is ready, the notification is returned, else a 0 pointer
Exceptions
protocol::ProtocolExceptionif a fragment was received multiple times

Definition at line 170 of file Assembly.cpp.

References logger, pool, and poolMutex.

bool rsb::spread::AssemblyPool::isPruning ( ) const

Tells whether the pool is currently pruning fragments or not.

This method is thread-safe.

Returns
true if the pool is currently pruning, else false

Definition at line 146 of file Assembly.cpp.

References pruningMutex, and pruningTask.

Referenced by setPruning().

Here is the caller graph for this function:

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.

Parameters
pruneif 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().

Here is the call graph for this function:

Here is the caller graph for this function:

Member Data Documentation

rsc::threading::ThreadedTaskExecutor rsb::spread::AssemblyPool::executor
private

Definition at line 181 of file Assembly.h.

Referenced by setPruning().

rsc::logging::LoggerPtr rsb::spread::AssemblyPool::logger
private

Definition at line 174 of file Assembly.h.

Referenced by add(), rsb::spread::AssemblyPool::PruningTask::execute(), and setPruning().

Pool rsb::spread::AssemblyPool::pool
private

Definition at line 175 of file Assembly.h.

Referenced by add(), rsb::spread::AssemblyPool::PruningTask::execute(), and setPruning().

boost::recursive_mutex rsb::spread::AssemblyPool::poolMutex
private

Definition at line 176 of file Assembly.h.

Referenced by add(), rsb::spread::AssemblyPool::PruningTask::execute(), and setPruning().

const unsigned int rsb::spread::AssemblyPool::pruningAgeS
private

Definition at line 178 of file Assembly.h.

Referenced by setPruning().

const unsigned int rsb::spread::AssemblyPool::pruningIntervalMs
private

Definition at line 179 of file Assembly.h.

Referenced by setPruning().

boost::recursive_mutex rsb::spread::AssemblyPool::pruningMutex
mutableprivate

Definition at line 182 of file Assembly.h.

Referenced by isPruning(), and setPruning().

rsc::threading::TaskPtr rsb::spread::AssemblyPool::pruningTask
private

Definition at line 183 of file Assembly.h.

Referenced by isPruning(), and setPruning().


The documentation for this class was generated from the following files: