You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I have one question related to Mutex, to create a mutex:
pMutex := hb_mutexCreate()
now to release/destroy I dont see nothing in the core, is only pMutex := nil good enough to destroy it?
Why we don't have hb_mutexDestroy( pMutex ) or hb_mutexRelease( pMutex )
Another question is, if I locked a mutex, Are there any way to verify it using the pMutex only?
function main()
local pMutex := hb_mutexCreate()
hb_threadStart( @test1(), pMutex )
hb_threadStart( @test2(), pMutex )
hb_threadWaitForAll()
pMutex := nil // <-- Is it enough to destroy mutex? why not some hb_mutexRelease( pMutex ) or hb_mutexDestroy( pMutex )
return nil
function test1( pMutex )
? "Lock"
hb_mutexLock( pMutex )
hb_idleSleep( 15 )
hb_mutexUnlock( pMutex )
? "UnLock"
return nil
function test2( pMutex )
// How to do something like?
/*
if hb_mutexIsLocked( pMutex )
? "Mutex is Locked..."
return nil
endif
// is not locked, so do something...
*/
return nil
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
I have one question related to Mutex, to create a mutex:
pMutex := hb_mutexCreate()
now to release/destroy I dont see nothing in the core, is only pMutex := nil good enough to destroy it?
Why we don't have hb_mutexDestroy( pMutex ) or hb_mutexRelease( pMutex )
Another question is, if I locked a mutex, Are there any way to verify it using the pMutex only?
And finally, are there any DOC about it:
?
Thanks
Beta Was this translation helpful? Give feedback.
All reactions