Semaphore>>wait:

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
4 messages Options
Reply | Threaded
Open this post in threaded view
|

Semaphore>>wait:

Steve Harris
When I tried Semaphore>>wait: aTimeoutMillis

I blew chunks with an error. Is another prescribed
method for waiting on a semaphore for a specified amount of
time or until signaled? (useful for blocking calls with timeout)?
Or doesn this really work and I'm just missing something?


Reply | Threaded
Open this post in threaded view
|

Re: Semaphore>>wait:

Christopher J. Demers
The comment in Semephore>>wait:ret: (which wait: calls) says:
"...At present the only valid values for timeout are,  INFINITE, meaning
wait for ever,
 and 0, meaning don't wait at all. The behaviour of these is as follows:
  INFINITE- Wait until the semaphore is signalled, answering WAIT_OBJECT_O.
  0  - If the receiver has excess signals, then decrement the count, and
    answer WAIT_OBJECT_O, otherwise return immediately without waiting,
    but answer WAIT_TIMEOUT. i.e this is a way to 'poll' a Semaphore."

You might have a look at Delay. For example:

d := (Delay forSeconds: 20).
[d wait. MessageBox notify: 'blah'] fork.
d signal.

Chris

Steve Harris <[hidden email]> wrote in message
news:[hidden email]...
> When I tried Semaphore>>wait: aTimeoutMillis
>
> I blew chunks with an error. Is another prescribed
> method for waiting on a semaphore for a specified amount of
> time or until signaled? (useful for blocking calls with timeout)?
> Or doesn this really work and I'm just missing something?


Reply | Threaded
Open this post in threaded view
|

Re: Semaphore>>wait:

Steve Harris
Thanks, Yes, I read the comment and was unsurprised by the result
but I need the functionality. I don't want to poll inorder to implement
a blocking call such as MyQueue getWithTimeout: aTimeout and I don't
want to introduce artificial delays in the flow through this queue
by using Delay.
Unfortunately I may not have a choice but it would be dissappointing.
Cheers

"Christopher J. Demers" <[hidden email]> wrote in message news:<ake6t7$1hs4in$[hidden email]>...

> The comment in Semephore>>wait:ret: (which wait: calls) says:
> "...At present the only valid values for timeout are,  INFINITE, meaning
> wait for ever,
>  and 0, meaning don't wait at all. The behaviour of these is as follows:
>   INFINITE- Wait until the semaphore is signalled, answering WAIT_OBJECT_O.
>   0  - If the receiver has excess signals, then decrement the count, and
>     answer WAIT_OBJECT_O, otherwise return immediately without waiting,
>     but answer WAIT_TIMEOUT. i.e this is a way to 'poll' a Semaphore."
>
> You might have a look at Delay. For example:
>
> d := (Delay forSeconds: 20).
> [d wait. MessageBox notify: 'blah'] fork.
> d signal.
>
> Chris
>
> Steve Harris <[hidden email]> wrote in message
> news:[hidden email]...
> > When I tried Semaphore>>wait: aTimeoutMillis
> >
> > I blew chunks with an error. Is another prescribed
> > method for waiting on a semaphore for a specified amount of
> > time or until signaled? (useful for blocking calls with timeout)?
> > Or doesn this really work and I'm just missing something?


Reply | Threaded
Open this post in threaded view
|

Re: Semaphore>>wait:

Steve Harris
In reply to this post by Christopher J. Demers
Doh, I'm a bone head, I read your answer to quickly.
Yes, that would work (though still not the best) but it definitely
works and is good enough. It is kind of a pain because I have to
a) fork off the process and b) make sure I kill it if a put happens
before the timeout. c)it's pretty inefficeint
but what the heck. I'll live.

"Christopher J. Demers" <[hidden email]> wrote in message news:<ake6t7$1hs4in$[hidden email]>...

> The comment in Semephore>>wait:ret: (which wait: calls) says:
> "...At present the only valid values for timeout are,  INFINITE, meaning
> wait for ever,
>  and 0, meaning don't wait at all. The behaviour of these is as follows:
>   INFINITE- Wait until the semaphore is signalled, answering WAIT_OBJECT_O.
>   0  - If the receiver has excess signals, then decrement the count, and
>     answer WAIT_OBJECT_O, otherwise return immediately without waiting,
>     but answer WAIT_TIMEOUT. i.e this is a way to 'poll' a Semaphore."
>
> You might have a look at Delay. For example:
>
> d := (Delay forSeconds: 20).
> [d wait. MessageBox notify: 'blah'] fork.
> d signal.
>
> Chris
>
> Steve Harris <[hidden email]> wrote in message
> news:[hidden email]...
> > When I tried Semaphore>>wait: aTimeoutMillis
> >
> > I blew chunks with an error. Is another prescribed
> > method for waiting on a semaphore for a specified amount of
> > time or until signaled? (useful for blocking calls with timeout)?
> > Or doesn this really work and I'm just missing something?