Hello Przemek

Przemyslaw Czerpak-2 wrote:
> 
> I will want to introduce two extensions for MT mode.
> 
> 1. allow to use hb_mutexCreate() as static variable initialization.
> 
>    If we unblock using hb_mutexCreate() as static variable initializer
>    (now we can use only fully optimized functions: static s :=
> HB_BITOR(1,2))
>    then the same code can be reduced to:
>       proc p()
>          static s_mtx := hb_mutexCreate()
>          [...]
>          hb_mutexLock()
>          [...]
>          hb_mutexUnlock()
>          [...]
>       return
> 
> 2. CRITICAL FUNCTION|PROCEDURE
>    - user cannot forgot about unlocking the mutex because it will be
> unlocked
>      by HVM automatically
>    - HVM will unlock them in all cases also when thread generate exception
>      like QUIT or BREAK so it's not necessary to use BEGIN SEQUENCE /
> ALWAYS
>      statment as protection, f.e. with above modification I can write code
>      like:
>          proc p()
>             static s_mtx := hb_mutexCreate()
>             hb_mutexLock()
>             [...do sth...]
>             hb_mutexUnlock()
>          return
>      but if [...do sth...] can generate exception, f.e. RT error then
>      I should add protection code which will always unlock the mutex:
>          proc p()
>             static s_mtx := hb_mutexCreate()
>             hb_mutexLock()
>             begin sequence
>                [...do sth...]
>             always
>                hb_mutexUnlock()
>             endsequence
>          return
>      With CRITICAL functions/procedures to reach the same effect it will
>      be enough to make:
>          critical proc p()
>             [...do sth...]
>          return
> 
> Both modifications are similar but they are not fully replaceable so
> I want to introduce both.
> 

Perfect. 

CRITICAL PROC p() is the easiest way. Can it be implemented in C also? Like
:

HB_FUNC_CRITICAL( SOMEFUNC )
{
   // do sth
}

Regards
Pritpal Bedi

-- 
View this message in context: 
http://www.nabble.com/MT-extensions-tp20230982p20233603.html
Sent from the Harbour - Dev mailing list archive at Nabble.com.

_______________________________________________
Harbour mailing list
Harbour@harbour-project.org
http://lists.harbour-project.org/mailman/listinfo/harbour

Reply via email to