Hi,
Is there an equivalent for Java's sleep and notify/notifyAll in FPC's rtl ?
Thanks,
Ido

Mailing lists / fpc-pascal / 2007-08
16 messages · 7 people · –
Reply by email Subscribe to this list Your subscription
Read-only archive. Use j and k to move between messages.
Hi,
Is there an equivalent for Java's sleep and notify/notifyAll in FPC's rtl ?
Thanks,
Ido
Is there an equivalent for Java's sleep and notify/notifyAll in FPC's rtl ?
I'm sorry. I don't know Java that well. Maybe it is easier to describe the exact behaviour that you want instead of drawing a parallel
Marco van de Voort wrote> Is there an equivalent for Java's sleep and notify/notifyAll in FPC's rtl ? I'm sorry. I don't know Java that well. Maybe it is easier to describe the exact behaviour that you want instead of drawing a parallel
Lets say I have synchronized threads, because I do not want to arrive to a race condition.
So I want one thread to sleep as long as another thread is running... now "sleep" or "wait" I don't remember, sleep to infinitum unless I'm notifying the thread.
Now if I have more then one thread (for example) that is looking for something to finish, I should need to tell every such thread to continue running, so I'll use notifyAll.
Ido
Maybe you can try
http://www.freepascal.org/docs-html/rtl/system/rtleventwaitfor.html
If this works, you can write a small example for the wiki: http://wiki.lazarus.freepascal.org/Multithreaded_Application_Tutorial
Mattias
Thanks, that's what I was looking for.
Mattias
Ido
On Thu, 23 Aug 2007 21:32:41 +0300 Maybe you can try…
En/na Mattias Gaertner ha escrit:
How are these different to the TEventObject,TSimpleEvent classes in syncobjs? Just curious, since I usually do with syncobjs, and I don't see a big difference between MyEvent.SetEvent/MyEvent.WaitFor and RTLEventSetEvent/RTLEventWaitFor
Bye
Luca Olivetti wroteHow are these different to the TEventObject,TSimpleEvent classes in syncobjs? Just curious, since I usually do with syncobjs, and I don't see a big difference between MyEvent.SetEvent/MyEvent.WaitFor and RTLEventSetEvent/RTLEventWaitFor
If you look at the source of syncobjs, you'll notice teventobject is just an OO coat for tbasicrtlevent.
Jonas
Is there an equivalent for Java's sleep and notify/notifyAll in FPC's rtl ? Ido…
ik wroteHi, Is there an equivalent for Java's sleep and notify/notifyAll in FPC's rtl ?
The "SetEvent" methods of "RtlWaitEvent" (notify) and "RTLSimpleEvent" (notify all), IIRC.
Vinzent.
If you look at the source of syncobjs, you'll notice teventobject is just an OO coat for…
Last time I looked this is only true for Win32, the Unix version seems to be very different and is implemented with semaphores. Is there a reason why those routines are not simply based POSIX condition variables?
Vinzent.
Yes: a single source base. All 'basic' threading routines are in the system unit, all the rest is based on that.
Michael.
Yes, I figured that this was the idea. I don't have access to the current SVN version (not before this evening when I am back home) to adequately show what I mean, but - from my bad memory - the question remains why
1) the Unix version makes so strange and wild efforts to support WaitFor with timeouts if there is pthread_cond_timed_wait() (and this is used elsewhere already) and
2) why the SyncObjs tEvent objects uses those semaphore stuff instead of the fixed RTLEvents.
Vinzent.
This I don't know; I didn't implement it.
2) why the SyncObjs tEvent objects uses those semaphore stuff instead of the fixed RTLEvents.
It's based on the Windows implementation, as far as I know ?
Michael.
Last time I looked this is only true for Win32, the Unix version seems to be very…
Someone submitted a patch a while ago to make this so for all platforms. The reason it was different for Unix was that this unit predates the existence of tbasicrtlevent.
Is there a reason why those routines are not simply based POSIX condition variables?
tbasicrtlevent for Unix is still not based on condition variables, because Windows events are persistent and condition variables are not.
Jonas
This I don't know; I didn't implement it. It's based on the Windows implementation, as…
The Windows "implementation" just aliases the standard Windows API primitives for these operations. Other platforms have to emulate them.
Jonas
Someone submitted a patch a while ago to make this so for all platforms. The reason it…
Jonas Maebe wrotetbasicrtlevent for Unix is still not based on condition variables, because Windows events are persistent and condition variables are not.
Call me stupid, but I was under the impression that this has been fixed by inserting the "IsSet" member in the IntRTLEvent structure (this fix also made RTLEventStartWait disappear for exactly that reason).
Vinzent.
If you insist :)
but I was under the impression that this has been fixed by inserting the "IsSet" member in the IntRTLEvent structure (this fix also made RTLEventStartWait disappear for exactly that reason).
There are two different event families: intrtlevent and basicrtlevent. I have no idea what the history behind the two different taxonomies is, nor what their supposed functional differences are. basicrtlevent was implemented from the start using semaphores, intrtlevent using conditional variables. syncobjs uses basicrtlevent.
It's indeed possible that by now due to all of the fixes everywhere, they both provide exactly the same functionality, but I would have to check (also the Windows implementation, to see whether there are any differences over there).
Jonas