gatb.core-API-0.0.0
ThreadGroup Class Reference

Implementation of IThreadGroup. More...

#include <System.hpp>

Inheritance diagram for ThreadGroup:
Inheritance graph

Public Member Functions

void add (void *(*mainloop)(void *), void *data)
 
void start ()
 
ISynchronizergetSynchro ()
 
size_t size () const
 
IThreadoperator[] (size_t idx)
 
void addException (system::Exception e)
 
bool hasExceptions () const
 
Exception getException () const
 
- Public Member Functions inherited from IThreadGroup
virtual ~IThreadGroup ()
 
- Public Member Functions inherited from ISmartPointer
virtual ~ISmartPointer ()
 
- Public Member Functions inherited from SmartPointer
void use ()
 
void forget ()
 

Static Public Member Functions

static IThreadGroupcreate ()
 
static void destroy (IThreadGroup *thr)
 
static IThreadGroupfind (IThread::Id id)
 
static bool findThreadInfo (IThread::Id id, std::pair< IThread *, size_t > &info)
 

Additional Inherited Members

- Protected Member Functions inherited from SmartPointer
 SmartPointer ()
 
virtual ~SmartPointer ()
 

Detailed Description

Implementation of IThreadGroup.

Member Function Documentation

void add ( void *(*)(void *)  mainloop,
void *  data 
)
virtual

Add a thread to the group. A thread is created and the provided mainloop is launched as the main function of this thread.

Parameters
[in]mainloop: mainloop of the added thread.
[in]data: data to be given to the main loop

Implements IThreadGroup.

void addException ( system::Exception  e)
inlinevirtual

This method is used to gather exceptions occurring during the execution of the threads of the group. By doing this, we can launch an ExceptionComposite when all the threads of the group are finished.

Parameters
[in]e: exception thrown by one of the thread.

Implements IThreadGroup.

IThreadGroup * create ( )
static

Create a IThreadGroup instance

Returns
the IThreadGroup instance
void destroy ( IThreadGroup thr)
static

Destroy a IThreadGroup

IThreadGroup * find ( IThread::Id  id)
static

Get a thread of the group from one id

Parameters
[in]id: the thread id
Returns
the IThreadGroup instance if found, NULL otherwise
bool findThreadInfo ( IThread::Id  id,
std::pair< IThread *, size_t > &  info 
)
static

Get thread information (IThread and index within the group);

Parameters
[in]id: the thread id
Returns
true if found
Exception getException ( ) const
inlinevirtual

Get an exception that holds all the information of exceptions that have occurred during the execution of the threads of the group.

Returns
the gathering exception.

Implements IThreadGroup.

ISynchronizer* getSynchro ( )
inlinevirtual

Get the synchronizer associated to this threads group.

Returns
the ISynchronizer instance.

Implements IThreadGroup.

bool hasExceptions ( ) const
inlinevirtual

Tells whether or not exceptions have been added to the thread group.

Returns
true if some exception has been added, false otherwise

Implements IThreadGroup.

IThread* operator[] ( size_t  idx)
inlinevirtual

Get the ith thread of the group.

Parameters
[in]idx: index of the thread in the group
Returns
the thread

Implements IThreadGroup.

size_t size ( ) const
inlinevirtual

Get the number of threads in the group.

Returns
the number of threads

Implements IThreadGroup.

void start ( )
virtual

Start all the threads of the group at the same time. Implementations should ensure this by some synchronization mechanism.

Implements IThreadGroup.


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