A "sleep" command without "receive"
Mon Feb 2 10:00:41 CET 2004
On 2/02, Corrado Santoro wrote:
| after T-> ok
| I've also seen that timer:sleep/1 implements the same routine... but...
| I use this timeout in a process that, after the timeout, receives something
| from another process. If the sending process sends data before the receiving
| process calls timer:sleep, the latter function returns immediatelly, picking
| also the message. This is *not* the behaviour I want to implement.
You seem confused about what the above code does: it does not get any
incoming message and sleeps for T milliseconds, regardless of whether
an incoming message arrives in the mean time or is already present.
The behaviour you describe would correspond to:
X -> X
after T -> ok
which is not the same thing. The code you gave says: "wait at maximum T
milliseconds for a message to arrive that matches *nothing*" (thus no
match is possible, and the process will wait for T milliseconds)
You are giving the time in milliseconds do you?
More information about the erlang-questions