Fawkes API  Fawkes Development Version
fawkes::ThreadCollector Class Referenceabstract

Thread collector. More...

#include <core/threading/thread_collector.h>

Inheritance diagram for fawkes::ThreadCollector:

Public Member Functions

virtual ~ThreadCollector ()
 Empty virtual destructor. More...
 
virtual void add (ThreadList &tl)=0
 Add multiple threads. More...
 
virtual void add (Thread *t)=0
 Add single thread. More...
 
virtual void remove (ThreadList &tl)=0
 Remove multiple threads. More...
 
virtual void remove (Thread *t)=0
 Remove single thread. More...
 
virtual void force_remove (fawkes::ThreadList &tl)=0
 Force removal of multiple threads. More...
 
virtual void force_remove (fawkes::Thread *t)=0
 Force removal of a single thread. More...
 

Detailed Description

Thread collector.

This interface is meant to provide a central place where to put threads to have them referenced somewhere. Threads my be added and removed at will. The main purpose of the collector is to tear down all threads if the collector is deleted thus providing a clean exit.

Additional functionality and aspect-specific behavior may be added in implementations.

Author
Tim Niemueller

Definition at line 34 of file thread_collector.h.

Constructor & Destructor Documentation

◆ ~ThreadCollector()

fawkes::ThreadCollector::~ThreadCollector ( )
virtual

Empty virtual destructor.

Definition at line 101 of file thread_collector.cpp.

Member Function Documentation

◆ add() [1/2]

void fawkes::ThreadCollector::add ( ThreadList tl)
pure virtual

Add multiple threads.

Adds all the threads in the list to the thread list. Implementations may throw an exception if this fails for whatever reason, read implementation documentation for details. The operation shall be atomic, either all threads are added successfully or none is added at all. If adding fails a CannotInitializeThreadException is thrown.

The thread is started if and only if initialization of all threads suceeds. A CannotInitializeThreadException is thrown if initialization failed for any thread.

Parameters
tllist of threads to add

Implemented in fawkes::ThreadManager.

Referenced by firevision::FuseServer::add_connection(), fawkes::FawkesNetworkServerThread::add_connection(), fawkes::FawkesNetworkManager::FawkesNetworkManager(), fawkes::FawkesNetworkServerThread::FawkesNetworkServerThread(), firevision::FuseServer::FuseServer(), FountainThread::init(), LuaAgentContinuousExecutionThread::init(), fawkes::PluginManager::load(), and FvBaseThread::register_for_camera().

◆ add() [2/2]

void fawkes::ThreadCollector::add ( Thread t)
pure virtual

Add single thread.

Adds the single thread to the internal (implementation specific) thread list. The thread is started if and only if initialization suceeds. A CannotInitializeThreadException is thrown if initialization failed.

Parameters
tthread to add

Implemented in fawkes::ThreadManager.

◆ force_remove() [1/2]

fawkes::ThreadCollector::force_remove ( fawkes::ThreadList tl)
pure virtual

Force removal of multiple threads.

Remove all threads in the thread list from this collector. If there is a thread in the supplied thread list that has never been collected no error shall be thrown but this just be silently ignored.

The threads are finalized, cancelled and joined. The result of the finalization is ignored and the thread is cancelled and joined in any case.

Parameters
tllist of threads to remove

Implemented in fawkes::ThreadManager.

Referenced by fawkes::PluginManager::~PluginManager().

◆ force_remove() [2/2]

fawkes::ThreadCollector::force_remove ( fawkes::Thread t)
pure virtual

Force removal of a single thread.

Remove the thread from the internal thread list. If the thread has never been collected no error shall be thrown but just be silently ignored. The threads are finalized, cancelled and joined. The result of the finalization is ignored and the thread is cancelled and joined in any case.

Parameters
tThread to remove.

Implemented in fawkes::ThreadManager.

◆ remove() [1/2]

fawkes::ThreadCollector::remove ( ThreadList tl)
pure virtual

Remove multiple threads.

Remove all threads in the thread list from this collector. If there is a thread in the supplied thread list that has never been collected no error shall be thrown but this just be silently ignored.

The threads are finalized, cancelled and joined. If the finalization fails for whatever reason the threads are NOT cancelled or stopped. In that case a CannotFinalizeThreadException is thrown.

Parameters
tllist of threads to remove

Implemented in fawkes::ThreadManager.

Referenced by FountainThread::finalize(), FvBaseThread::finalize(), LuaAgentContinuousExecutionThread::finalize(), fawkes::FawkesNetworkServerThread::loop(), firevision::FuseServer::loop(), FvBaseThread::loop(), LuaAgentContinuousExecutionThread::loop(), fawkes::PluginManager::unload(), fawkes::FawkesNetworkManager::~FawkesNetworkManager(), fawkes::FawkesNetworkServerThread::~FawkesNetworkServerThread(), FountainThread::~FountainThread(), and firevision::FuseServer::~FuseServer().

◆ remove() [2/2]

fawkes::ThreadCollector::remove ( Thread t)
pure virtual

Remove single thread.

Remove the thread from the internal thread list. If the thread has never been collected no error shall be thrown but just be silently ignored. The thread is finalized, cancelled and joined. If the finalization fails for whatever reason the thread is NOT cancelled or stopped. In that case a CannotFinalizeThreadException is thrown.

Parameters
tThread to remove.

Implemented in fawkes::ThreadManager.


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