Back to index

salome-kernel  6.5.0
Public Member Functions | Private Attributes
KERNEL_PY.kernel.threadhelper.PeriodicTimer Class Reference

List of all members.

Public Member Functions

def __init__
def defaultPeriodicAction
def run
def stop

Private Attributes

 _periodic_action
 _ended_action
 _loopdelay
 _initdelay
 _running
 _ended_argv
 _runtime

Detailed Description

Cette classe permet d'amorcer un compte-�-rebours p�riodique pour
op�rer un m�canisme de pooling. On d�finit la fonction appell�e
p�riodiquement et la fonction terminale.

Definition at line 178 of file threadhelper.py.


Constructor & Destructor Documentation

def KERNEL_PY.kernel.threadhelper.PeriodicTimer.__init__ (   self,
  loopdelay,
  initdelay = 0,
  periodic_action = None,
  ended_action = None,
  ended_argv 
)

Definition at line 187 of file threadhelper.py.

00187 
00188                   *ended_argv ):
00189 
00190         if periodic_action is None:
00191             self._periodic_action = self.defaultPeriodicAction
00192         else:
00193             self._periodic_action = periodic_action
00194         self._ended_action = ended_action
00195         self._loopdelay = loopdelay
00196         self._initdelay = initdelay
00197         self._running = CONTINUE
00198         self._ended_argv    = ended_argv
00199         threading.Thread.__init__( self )


Member Function Documentation

Les fonctions 'periodicAction' retournent CONTINU ou STOP
apr�s avoir ex�cut� l'action de fin de boucle. Si STOP est
retourn�, le cycle est interrompu. 

Definition at line 200 of file threadhelper.py.

00200 
00201     def defaultPeriodicAction():
00202         """
00203         Les fonctions 'periodicAction' retournent CONTINU ou STOP
00204         apr�s avoir ex�cut� l'action de fin de boucle. Si STOP est
00205         retourn�, le cycle est interrompu. 
00206         """
00207         return CONTINU

Definition at line 208 of file threadhelper.py.

00208 
00209     def run( self ):
00210         if self._initdelay:
00211             time.sleep( self._initdelay )
00212         self._runtime = time.time()
00213         while self._running == CONTINUE:
00214             start = time.time()
00215             self._running  = self._periodic_action()
00216             self._runtime += self._loopdelay
00217             time.sleep( max( 0, self._runtime - start ) )
00218         if self._ended_action is not None:
00219             self._ended_action( *self._ended_argv )

Definition at line 220 of file threadhelper.py.

00220 
00221     def stop( self ):
00222         self._running = STOP
00223 
00224 
00225 
00226 #
00227 # ======================================================
00228 # Fonctions de test unitaire
00229 # ======================================================
00230 #
00231 
# ======================================================

Member Data Documentation

Definition at line 193 of file threadhelper.py.

Definition at line 197 of file threadhelper.py.

Definition at line 195 of file threadhelper.py.

Definition at line 194 of file threadhelper.py.

Definition at line 190 of file threadhelper.py.

Definition at line 196 of file threadhelper.py.

Definition at line 211 of file threadhelper.py.


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