Update function LockMutex and WaitSemaphore

Got an idea for enhancing PureBasic? New command(s) you'd like to see?
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Update function LockMutex and WaitSemaphore

Post by User_Russian »

I propose to add optional parameter to the function LockMutex and WaitSemaphore.

Code: Select all

LockMutex(Mutex [,Timeout])
WaitSemaphore(Semaphore [,Timeout])
The parameter "Timeout" sets the wait object.
If the object is received, function returns #True.
Or #False, if the exit the timeout.
User avatar
STARGÅTE
Addict
Addict
Posts: 2227
Joined: Thu Jan 10, 2008 1:30 pm
Location: Germany, Glienicke
Contact:

Re: Update function LockMutex and WaitSemaphore

Post by STARGÅTE »

Locked is locked,

you want to check, use TryLockMutex(Mutex) or TrySemaphore(Semaphore).
PB 6.01 ― Win 10, 21H2 ― Ryzen 9 3900X, 32 GB ― NVIDIA GeForce RTX 3080 ― Vivaldi 6.0 ― www.unionbytes.de
Lizard - Script language for symbolic calculations and moreTypeface - Sprite-based font include/module
User_Russian
Addict
Addict
Posts: 1520
Joined: Wed Nov 12, 2008 5:01 pm
Location: Russia

Re: Update function LockMutex and WaitSemaphore

Post by User_Russian »

This option will not work, because in the program, the mutex is locked most of the time and only for a moment, unlock. Therefore, the timeout should be counted at the system level, not the application.

In addition, exit on timeout to avoid a deadlock flows.
User avatar
RichAlgeni
Addict
Addict
Posts: 935
Joined: Wed Sep 22, 2010 1:50 am
Location: Bradenton, FL

Re: Update function LockMutex and WaitSemaphore

Post by RichAlgeni »

User_Russian wrote:the mutex is locked most of the time
User_Russian, I find myself wondering under what conditions your mutex would be locked most of the time. It almost seems counter-intuitive.
Post Reply