OpenWalnut
1.5.0dev
|
A thread calculating the reaction for a certain part of the domain. More...
Public Member Functions | |
PatternThread (std::size_t id, std::size_t max, std::shared_ptr< WCondition > const mainThreadContinueCondition, std::shared_ptr< WCondition > const waitForMainThreadCondition, WCounter *const counter) | |
Constructor. More... | |
~PatternThread () | |
Destructor. More... | |
void | setDomainSize (std::size_t sizeX, std::size_t sizeY, std::size_t sizeZ) |
Set the domain size. More... | |
void | setSpotFactor (float spotFactor) |
Set the spot factor. More... | |
void | setDiffusionConstants (float d1, float d2) |
Set the diffusion constants. More... | |
void | setBufferPointers (std::vector< float > const *concentration1, std::vector< float > const *concentration2, std::vector< float > const *noise, std::vector< float > *delta1, std::vector< float > *delta2) |
Set the pointers to the buffer all threads share. More... | |
virtual void | threadMain () |
The entry point for the thread. More... | |
void | finish () |
Tells the thread to finish. More... | |
Public Member Functions inherited from WThreadedRunner | |
WThreadedRunner () | |
Default constructor. More... | |
virtual | ~WThreadedRunner () |
Destructor. More... | |
virtual void | run () |
Run thread. More... | |
void | run (THREADFUNCTION f) |
Run thread. More... | |
void | wait (bool requestFinish=false) |
Wait for the thread to be finished. More... | |
virtual void | requestStop () |
This method's purpose is to request a stop without waiting for it. More... | |
virtual boost::signals2::connection | subscribeSignal (THREAD_SIGNAL signal, t_ThreadErrorSignalHandlerType notifier) |
Connects a specified notify function with a signal this thread instance is offering. More... | |
const WBoolFlag & | isCrashed () const |
Checks whether this thread has been crashed. More... | |
const std::string & | getCrashMessage () const |
Get the message of the exception finally causing the crash. More... | |
void | setThreadName (std::string name) |
Set the name of the thread. More... | |
std::string | getThreadName () const |
Returns the current thread name. More... | |
Private Attributes | |
std::size_t | m_id |
The number of this thread. More... | |
std::size_t | m_maxThreads |
The maximum number of threads. More... | |
std::size_t | m_sizeX |
The size of the domain in x-direction. More... | |
std::size_t | m_sizeY |
The size of the domain in y-direction. More... | |
std::size_t | m_sizeZ |
The size of the domain in z-direction. More... | |
float | m_spotFactor |
The spot factor. More... | |
float | m_diffusionConstant1 |
The first diffusion constant. More... | |
float | m_diffusionConstant2 |
The second diffusion constant. More... | |
std::vector< float > const * | m_concentration1 |
The buffer for the concentration of the first substance. More... | |
std::vector< float > const * | m_concentration2 |
The buffer for the concentration of the second substance. More... | |
std::vector< float > const * | m_noise |
A constant buffer containing a random value per voxel. More... | |
std::vector< float > * | m_delta1 |
A buffer that will store the change in concentration for the first substance. More... | |
std::vector< float > * | m_delta2 |
A buffer that will store the change in concentration for the second substance. More... | |
std::shared_ptr< WCondition > | m_mainThreadContinueCondition |
The condition used to tell the main thread we are done for this iteration. More... | |
std::shared_ptr< WCondition > | m_waitForMainThreadCondition |
The condition used by the main thread to notify we are ready to start the next iteration. More... | |
WCounter *const | m_counter |
Counts the number of threads done with the current iteration. More... | |
bool | m_stop |
Whether we are to stop the thread. More... | |
Additional Inherited Members | |
Public Types inherited from WThreadedRunner | |
typedef std::shared_ptr< WThreadedRunner > | SPtr |
Abbreviation to a shared_ptr to this type. More... | |
typedef std::shared_ptr< const WThreadedRunner > | ConstSPtr |
Abbreviation to a const shared_ptr to this type. More... | |
typedef boost::function< void(void) > | THREADFUNCTION |
Type used for simple thread functions. More... | |
Static Public Member Functions inherited from WThreadedRunner | |
static void | setThisThreadName (std::string name) |
Static function to set the name of the calling thread. More... | |
Protected Member Functions inherited from WThreadedRunner | |
virtual void | notifyStop () |
Gets called when the thread should be stopped. More... | |
void | yield () const |
Give remaining execution timeslice to another thread. More... | |
void | sleep (const int32_t t) const |
Sets thread asleep. More... | |
void | msleep (const int32_t t) const |
Sets thread asleep. More... | |
void | waitForStop () |
Let the thread sleep until a stop request was given. More... | |
virtual void | onThreadException (const WException &e) |
This method is called if an exception was caught, which came from the custom thread code. More... | |
void | handleDeadlyException (const WException &e, std::string sender="WThreadedRunner") |
Handle the specified exception which was not caught in the thread, which basically means the thread has crashed. More... | |
Protected Attributes inherited from WThreadedRunner | |
boost::thread | m_thread |
Thread instance. More... | |
WBoolFlag | m_shutdownFlag |
Condition getting fired whenever the thread should quit. More... | |
WBoolFlag | m_isCrashed |
True whenever an exception is thrown during threadMain. More... | |
std::string | m_crashMessage |
The crash message. More... | |
A thread calculating the reaction for a certain part of the domain.
The thread is constructed once. Using the conditions provided to the constructor, we can synchronize the pattern threads and the main thread.
Definition at line 98 of file WTuringPatternCreator.h.
WTuringPatternCreator::PatternThread::PatternThread | ( | std::size_t | id, |
std::size_t | max, | ||
std::shared_ptr< WCondition > const | mainThreadContinueCondition, | ||
std::shared_ptr< WCondition > const | waitForMainThreadCondition, | ||
WCounter *const | counter | ||
) |
Constructor.
id | The id of the thread. Must be smaller than max. |
max | The number of threads. |
mainThreadContinueCondition | The condition we use to tell the main thread we are done for the current iteration. |
waitForMainThreadCondition | The condition used to wait for the main thread to prepare the next iteration. |
counter | A counter used by all threads to signal how many have finished the current iteration. |
Definition at line 158 of file WTuringPatternCreator.cpp.
WTuringPatternCreator::PatternThread::~PatternThread | ( | ) |
Destructor.
Definition at line 178 of file WTuringPatternCreator.cpp.
void WTuringPatternCreator::PatternThread::finish | ( | ) |
Tells the thread to finish.
Note that the waiting condition also needs to be notified for the thread to actually finish.
Definition at line 306 of file WTuringPatternCreator.cpp.
void WTuringPatternCreator::PatternThread::setBufferPointers | ( | std::vector< float > const * | concentration1, |
std::vector< float > const * | concentration2, | ||
std::vector< float > const * | noise, | ||
std::vector< float > * | delta1, | ||
std::vector< float > * | delta2 | ||
) |
Set the pointers to the buffer all threads share.
concentration1 | The buffer for the concentration of the first substance. |
concentration2 | The buffer for the concentration of the second substance. |
noise | A constant buffer containing a random value per voxel. |
delta1 | A buffer that will store the change in concentration for the first substance. |
delta2 | A buffer that will store the change in concentration for the second substance. |
Definition at line 289 of file WTuringPatternCreator.cpp.
void WTuringPatternCreator::PatternThread::setDiffusionConstants | ( | float | d1, |
float | d2 | ||
) |
Set the diffusion constants.
d1 | First diffusion constant. |
d2 | Second diffusion constant. |
Definition at line 182 of file WTuringPatternCreator.cpp.
void WTuringPatternCreator::PatternThread::setDomainSize | ( | std::size_t | sizeX, |
std::size_t | sizeY, | ||
std::size_t | sizeZ | ||
) |
Set the domain size.
sizeX | The size of the 3D regular domain in x-direction. |
sizeY | The size of the 3D regular domain in y-direction. |
sizeZ | The size of the 3D regular domain in z-direction. |
Definition at line 198 of file WTuringPatternCreator.cpp.
void WTuringPatternCreator::PatternThread::setSpotFactor | ( | float | spotFactor | ) |
Set the spot factor.
spotFactor | The spot factor. |
Definition at line 191 of file WTuringPatternCreator.cpp.
|
virtual |
The entry point for the thread.
Reimplemented from WThreadedRunner.
Definition at line 209 of file WTuringPatternCreator.cpp.
|
private |
The buffer for the concentration of the first substance.
Definition at line 192 of file WTuringPatternCreator.h.
|
private |
The buffer for the concentration of the second substance.
Definition at line 195 of file WTuringPatternCreator.h.
|
private |
Counts the number of threads done with the current iteration.
Definition at line 213 of file WTuringPatternCreator.h.
|
private |
A buffer that will store the change in concentration for the first substance.
Definition at line 201 of file WTuringPatternCreator.h.
|
private |
A buffer that will store the change in concentration for the second substance.
Definition at line 204 of file WTuringPatternCreator.h.
|
private |
The first diffusion constant.
Definition at line 186 of file WTuringPatternCreator.h.
|
private |
The second diffusion constant.
Definition at line 189 of file WTuringPatternCreator.h.
|
private |
The number of this thread.
Definition at line 168 of file WTuringPatternCreator.h.
|
private |
The condition used to tell the main thread we are done for this iteration.
Definition at line 207 of file WTuringPatternCreator.h.
|
private |
The maximum number of threads.
Definition at line 171 of file WTuringPatternCreator.h.
|
private |
A constant buffer containing a random value per voxel.
Definition at line 198 of file WTuringPatternCreator.h.
|
private |
The size of the domain in x-direction.
Definition at line 174 of file WTuringPatternCreator.h.
|
private |
The size of the domain in y-direction.
Definition at line 177 of file WTuringPatternCreator.h.
|
private |
The size of the domain in z-direction.
Definition at line 180 of file WTuringPatternCreator.h.
|
private |
The spot factor.
Definition at line 183 of file WTuringPatternCreator.h.
|
private |
Whether we are to stop the thread.
Definition at line 216 of file WTuringPatternCreator.h.
|
private |
The condition used by the main thread to notify we are ready to start the next iteration.
Definition at line 210 of file WTuringPatternCreator.h.