ISemaphore missing in action

delphi package - easy access to kernel objects etc.
Post Reply
David Gottschalk
Posts: 4
Joined: Tue Jun 15, 2004 11:17 pm

ISemaphore missing in action

Post by David Gottschalk »

Hello,

I want to convert some existing code to using the madKernel interfaces. In one place I use WaitForMultipleObjects to wait on a semaphore and an event. I was thinking I would use

function WaitFor (const objects : array of IBasic;
waitAll : boolean = false;
milliseconds : cardinal = INFINITE;
handleMessages : boolean = true;
msgs : TWaitForMessages = [];
alertable : boolean = false ) : integer; overload;

but it seems there is no ISemaphore.

Is there a reason to not have an ISemaphore?

Should I still use WaitForMultipleObjects and feed in the handle from the IEvent?

thanks
madshi
Site Admin
Posts: 10754
Joined: Sun Mar 21, 2004 5:25 pm

Post by madshi »

You're right that there's no ISemaphore. Maybe I should add that. Anyway, you could use "yourSemaphore := madKernel.Handle(yourSemaphoreHandle, false)" to convert your manually created semaphore handle into a madKernel compatible "IHandle" instance. After having done that you can use "WaitFor([yourEvent, yourSemaphore])". Of course you can also use WaitForMultipleObjects and feed in "yourEvent.Handle.Handle" (the first "Handle" returns an IHandle instance, then calling "IHandle.Handle" finally returns a standard win32 handle dword for use with WaitForMultipleObjects).
David Gottschalk
Posts: 4
Joined: Tue Jun 15, 2004 11:17 pm

Post by David Gottschalk »

Hello,

I will convert it to an IHandle instance as the other way reduces the advantages of using your code. If you do create an ISemaphore I will switch to using that.

thanks
Post Reply