On Wed, 11 Feb 2009, Mindaugas Kavaliauskas wrote:
> Hi,
> has each thread a separate errorblock, or they share the same?

Errorblock is thread local but not inherited from parent thread.
When new thread is created then ClipInit() is executed which creates
public variable GetList, initialize errorblock by calling ERRORSYS()
and SETKEY F1 to user HELP() function if it exists. See ClipInit()
function in source/vm/harbinit.prg for details. AFAIR you overloaded
this function so please remember that your code will be executed
when new thread is created.
Errorblock and RT errors are thread local. RT error can interrupt
only given thread not the whole application unless it was not generated
by main thread. In such case QUIT request is send to all existing threads.
In such way works also QUIT/__QUIT() command/function. It terminates
only thread which executed it with the exception to main thread.
Math error handler and math error block are also thread local and
not inherited from parent thread. If you are using them in your code
then you should initialize them for each thread.

Here is list of attributes which are thread local but inherited from
parent thread:
      - code page
      - language
      - SETs
      - default RDD
      - active GT driver/window
      - I18N translation set
To this list we probably should add macro compiler features setting
(hb_setMacro()) which is now thread local but not inherited.
But IMHO we should move it to SETs (_SET_MACROFLAG) so it will be
inherited just like any other SETs. I think we should make it ASAP.

Here is the list of .prg MT functions:

   hb_threadStart( [<nThreadAttrs> ,] <@sStart()> | <bStart> [, <params,...> ] 
) -> <pThID>
   hb_threadSelf() -> <pThID> | NIL
   hb_threadId( [ <pThID> ] ) -> <nThNo>
   hb_threadJoin( <pThID> [, @<xRetCode> ] ) -> <lOK>
   hb_threadDetach( <pThID> ) -> <lOK>
 * hb_threadQuitRequest( <pThID> ) -> <lOK> /* can be ignored !!! */
   hb_threadTerminateAll() -> NIL
   hb_threadWaitForAll() -> NIL
   hb_threadWait( <pThID> | <apThID>, [ <nTimeOut> ] [, <lAll> ] ) => <nThInd> 
| <nThCount> | 0
   hb_threadOnce( @<onceControl> [, <bAction> ] ) -> <lFirstCall>
   hb_mutexCreate() -> <pMtx>
   hb_mutexLock( <pMtx> [, <nTimeOut> ] ) -> <lLocked>
   hb_mutexUnlock( <pMtx> ) -> <lOK>
   hb_mutexNotify( <pMtx> [, <xVal>] ) -> NIL
   hb_mutexNotifyAll( <pMtx> [, <xVal>] ) -> NIL
   hb_mutexSubscribe( <pMtx>, [ <nTimeOut> ] [, @<xSubscribed> ] ) -> 
<lSubscribed>
   hb_mutexSubscribeNow( <pMtx>, [ <nTimeOut> ] [, @<xSubscribed> ] ) -> 
<lSubscribed>

HTH,

best regards,
Przemek
_______________________________________________
Harbour mailing list
[email protected]
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to