ISemaphore missing in action

delphi package - easy access to kernel objects etc.

ISemaphore missing in action

Postby David Gottschalk » Tue Jul 01, 2008 6:19 am

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
David Gottschalk
 
Posts: 4
Joined: Tue Jun 15, 2004 11:17 pm

Postby madshi » Thu Jul 03, 2008 9:41 pm

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).
madshi
Site Admin
 
Posts: 9414
Joined: Sun Mar 21, 2004 5:25 pm

Postby David Gottschalk » Sun Jul 06, 2008 11:49 pm

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
David Gottschalk
 
Posts: 4
Joined: Tue Jun 15, 2004 11:17 pm


Return to madKernel

Who is online

Users browsing this forum: No registered users and 3 guests

cron