#include <PsnMultiThreadedAsynchronousScheduler.h>
Inheritance diagram for PsnMultiThreadedAsynchronousScheduler:


Public Methods | |
| PsnMultiThreadedAsynchronousScheduler (unsigned int numberOfSteps, unsigned int numberOfThreads) | |
| virtual | ~PsnMultiThreadedAsynchronousScheduler () |
| virtual void | addToScheduable (PsnReferenceObjectHandle *ref, unsigned int when) |
| redefine so that simulated objects are assigned to threads in a cyclic manner | |
| virtual void | removeFromScheduable (PsnReferenceObjectHandle *ref) |
| redefine to remove the simulated object from schedulers local to a thread | |
| virtual void | schedule (PsnReferenceObjectHandle *ref) |
| mark a scheduable object as active | |
| virtual void | unschedule (PsnReferenceObjectHandle *ref) |
| mark a scheduable object as inactive | |
| virtual void | runStep (unsigned int which) |
| run a simulation step | |
| virtual void | runAsynchronous () |
Static Protected Methods | |
| void * | _asynchronousThreadContainer (void *) |
Protected Attributes | |
| PsnMutexLock | _runDataAccess |
| bool | _running |
| bool | _started |
| PsnCondition | _runCondition |
| PsnReferenceObjectHandle * | _asyncRef |
| PsName | _nameOfAsynchronousObject |
| pthread_t | _asynchronousThreadId |
This scheduler is able to schedule asynchronous threads with respect to the simulation.
Definition at line 33 of file PsnMultiThreadedAsynchronousScheduler.h.
|
||||||||||||
|
Definition at line 26 of file PsnMultiThreadedAsynchronousScheduler.cxx.
00027 : 00028 PsnMultiThreadedScheduler(numberOfSteps, numberOfThreads,true), 00029 _running (false), 00030 _started (false), 00031 _nameOfAsynchronousObject("visu") 00032 { 00033 cerr<<"Warning : using a experimental scheduler. UNSUPPORTED"<<endl; 00034 cerr<<"Only supports ONE asynchronous object"<<endl; 00035 } |
|
|
Definition at line 37 of file PsnMultiThreadedAsynchronousScheduler.cxx.
00037 {
00038 }
|
|
|
Definition at line 111 of file PsnMultiThreadedAsynchronousScheduler.cxx. References runAsynchronous(). Referenced by addToScheduable().
00111 {
00112 PsnMultiThreadedAsynchronousScheduler * scheduler = (PsnMultiThreadedAsynchronousScheduler *) theScheduler ;
00113
00114 scheduler->runAsynchronous() ;
00115
00116 return scheduler ;
00117 }
|
|
||||||||||||
|
|
redefine to remove the simulated object from schedulers local to a thread
Reimplemented from PsnMultiThreadedScheduler. Definition at line 59 of file PsnMultiThreadedAsynchronousScheduler.cxx. References _asyncRef, and PsnMultiThreadedScheduler::removeFromScheduable().
00059 {
00060 if ( ref == _asyncRef ) {
00061 //nothing to do : the asynchronous thread has been stopped. destroying it would be to painfull code to write !
00062 }
00063 else {
00064 PsnMultiThreadedScheduler::removeFromScheduable ( ref );
00065 }
00066 } ;
|
|
|
Definition at line 121 of file PsnMultiThreadedAsynchronousScheduler.cxx. References _runCondition, _runDataAccess, _running, _started, PsnMutexLock::protect(), PsnCondition::signalChange(), PsnMutexLock::unprotect(), and PsnCondition::waitForChange(). Referenced by _asynchronousThreadContainer().
00121 {
00122 bool init = false ;
00123 _runDataAccess.protect() ;
00124 while (!_started) {
00125 _runDataAccess.unprotect() ;
00126 _runCondition.waitForChange( _runDataAccess ) ;
00127 }
00128
00129 _runDataAccess.unprotect() ;
00130
00131 assert (false ) ;
00132 //_asyncRef->getSimulatedObject().init() ;
00133
00134 while (true) {
00135 _runDataAccess.protect() ;
00136
00137 while (!(_running && _started) ) {
00138 _runDataAccess.unprotect() ;
00139 _runCondition.waitForChange( _runDataAccess ) ;
00140
00141 }
00142
00143 _runDataAccess.unprotect() ;
00144
00145 try {
00146
00147 assert (false) ;
00148 //_asyncRef->getSimulatedObject().compute() ;
00149
00150 }
00151 catch (PsUnInitialisedAttributeException & e) {
00152 _runDataAccess.protect() ;
00153 _started = false ;
00154 _runDataAccess.unprotect() ;
00155 _runCondition.signalChange() ;
00156 }
00157 }
00158 }
|
|
|
run a simulation step
Reimplemented from PsnMultiThreadedScheduler. Definition at line 96 of file PsnMultiThreadedAsynchronousScheduler.cxx. References _runCondition, _runDataAccess, _started, PsnMutexLock::protect(), PsnMultiThreadedScheduler::runStep(), PsnCondition::signalChange(), and PsnMutexLock::unprotect().
00096 {
00097 _runDataAccess.protect() ;
00098 if (!_started) {
00099 _started = true ;
00100 _runDataAccess.unprotect() ;
00101 _runCondition.signalChange() ;
00102 }
00103 else {
00104 _runDataAccess.unprotect() ;
00105 }
00106 PsnMultiThreadedScheduler::runStep( which ) ;
00107 }
|
|
|
mark a scheduable object as active
Reimplemented from PsnMultiThreadedScheduler. Definition at line 70 of file PsnMultiThreadedAsynchronousScheduler.cxx. References _asyncRef, _runCondition, _runDataAccess, _running, PsnMutexLock::protect(), PsnMultiThreadedScheduler::schedule(), PsnCondition::signalChange(), and PsnMutexLock::unprotect().
00070 {
00071 if ( ref == _asyncRef ) {
00072 _runDataAccess.protect() ;
00073 _running = true ;
00074 _runDataAccess.unprotect () ;
00075 _runCondition.signalChange() ;
00076 }
00077 else {
00078 PsnMultiThreadedScheduler::schedule ( ref );
00079 }
00080 }
|
|
|
mark a scheduable object as inactive
Reimplemented from PsnMultiThreadedScheduler. Definition at line 84 of file PsnMultiThreadedAsynchronousScheduler.cxx. References _asyncRef, _runCondition, _runDataAccess, _running, PsnMutexLock::protect(), PsnCondition::signalChange(), PsnMutexLock::unprotect(), and PsnMultiThreadedScheduler::unschedule().
00084 {
00085 if ( ref == _asyncRef ) {
00086 _runDataAccess.protect () ;
00087 _running = false ;
00088 _runDataAccess.unprotect () ;
00089 _runCondition.signalChange() ;
00090 }
00091 else {
00092 PsnMultiThreadedScheduler::unschedule ( ref );
00093 }
00094 }
|
|
|
Definition at line 56 of file PsnMultiThreadedAsynchronousScheduler.h. Referenced by addToScheduable(). |
|
|
Definition at line 54 of file PsnMultiThreadedAsynchronousScheduler.h. Referenced by addToScheduable(), removeFromScheduable(), schedule(), and unschedule(). |
|
|
Definition at line 55 of file PsnMultiThreadedAsynchronousScheduler.h. Referenced by addToScheduable(). |
|
|
Definition at line 53 of file PsnMultiThreadedAsynchronousScheduler.h. Referenced by runAsynchronous(), runStep(), schedule(), and unschedule(). |
|
|
Definition at line 50 of file PsnMultiThreadedAsynchronousScheduler.h. Referenced by runAsynchronous(), runStep(), schedule(), and unschedule(). |
|
|
Definition at line 51 of file PsnMultiThreadedAsynchronousScheduler.h. Referenced by runAsynchronous(), schedule(), and unschedule(). |
|
|
Definition at line 52 of file PsnMultiThreadedAsynchronousScheduler.h. Referenced by runAsynchronous(), and runStep(). |
| Documentation generated on Mon Nov 25 15:26:11 2002 |
Generated with doxygen 1.2.12 by Dimitri van Heesch , 1997-2001 |