2010-02-25 14:32 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)

* harbour/contrib/hbxpp/tthreadx.prg
    + added paramter validation in THREAD:setInterval() and
      THREAD:setStartTime()
    + added support for THREAD:startTime
    * updated TODO notes
This commit is contained in:
Przemyslaw Czerpak
2010-02-25 13:32:21 +00:00
parent dfb423aeb9
commit bda62b8d16
2 changed files with 51 additions and 13 deletions

View File

@@ -17,6 +17,13 @@
past entries belonging to author(s): Viktor Szakats.
*/
2010-02-25 14:32 UTC+0100 Przemyslaw Czerpak (druzus/at/priv.onet.pl)
* harbour/contrib/hbxpp/tthreadx.prg
+ added paramter validation in THREAD:setInterval() and
THREAD:setStartTime()
+ added support for THREAD:startTime
* updated TODO notes
2010-02-25 13:41 UTC+0100 Viktor Szakats (harbour.01 syenar.hu)
* include/hbdefs.h
+ Added HB_FUNC_TRANSLATE() macro to replace this logic:

View File

@@ -144,6 +144,13 @@ METHOD new( ... ) CLASS THREAD
IF ISNUMBER( nMaxStackSize )
::maxStackSize := nMaxStackSize
ENDIF
/* TODO: Create new thread here and suspend its execution
* Then :START() method only resumes this thread instead
* of creating new one.
* xBase++ seems to work in such way.
*/
/* TODO: do not ignore thread stack size set by user in ::maxStackSize */
ENDIF
::Init( ... )
RETURN Self
@@ -165,10 +172,15 @@ METHOD quit( xResult, nRestart ) CLASS THREAD
RETURN NIL
METHOD setInterval( nHSeconds ) CLASS THREAD
IF nHSeconds == NIL .OR. ISNUMBER( nHSeconds )
::interval := nHSeconds
IF ISNUMBER( nHSeconds ) .AND. Int( nHSeconds ) >= 0
::interval := Int( nHSeconds )
ELSEIF PCount() > 0 .OR. nHSeconds == NIL
::interval := NIL
ELSE
/* TODO: RT Error */
RETURN .F.
ENDIF
RETURN .F.
RETURN .T.
METHOD setPriority( nPriority ) CLASS THREAD
/* TODO: add thread priority setting */
@@ -178,17 +190,21 @@ METHOD setPriority( nPriority ) CLASS THREAD
RETURN .F.
METHOD setStartTime( nSeconds ) CLASS THREAD
/* TODO: add such functionality */
IF ISNUMBER( nSeconds )
IF nSeconds < 0 .OR. nSeconds > 86400
RETURN .F.
ENDIF
::startTime := nSeconds
ELSEIF nSeconds == NIL
ELSEIF PCount() > 0 .OR. nSeconds == NIL
::startTime := NIL
ELSE
/* TODO: RT Error */
RETURN .F.
ENDIF
RETURN .F.
RETURN .T.
METHOD start( xAction, ... ) CLASS THREAD
/* TODO: thread stack size set by user ::maxStackSize */
IF ::active
RETURN .F.
@@ -198,9 +214,19 @@ METHOD start( xAction, ... ) CLASS THREAD
LOCAL nTime
ThreadObject( Self )
::active := .T.
::startCount++
IF ISNUMBER( ::startTime )
nTime := ::startTime - Seconds()
IF nTime < 0
nTime += 86400
ENDIF
hb_idleSleep( nTime )
::startTime := NIL
ENDIF
::atStart( ... )
IF ValType( ::_atStart ) == "B"
EVAL( ::_atStart, ... )
@@ -223,13 +249,12 @@ METHOD start( xAction, ... ) CLASS THREAD
nTime := Int( ( hb_milliSeconds() - nTime ) / 10 )
::deltaTime := nTime
/* TODO: when ::startTime is set execution is suspended
* but I do not know the exact conditions and how
* it can be resumed
*/
IF !ISNUMBER( ::interval )
::startTime := NIL
::atEnd( ... )
IF ValType( ::_atEnd ) == "B"
EVAL( ::_atEnd, ... )
ENDIF
::active := .F.
EXIT
ENDIF
@@ -241,6 +266,12 @@ METHOD start( xAction, ... ) CLASS THREAD
ENDDO
::atEnd( ... )
IF ValType( ::_atEnd ) == "B"
EVAL( ::_atEnd, ... )
ENDIF
::active := .F.
RETURN NIL
}, ... )