[gambit-list] network ports/sockets question

Adrien Piérard pierarda at iro.umontreal.ca
Tue Dec 28 23:20:26 EST 2010


>> You can use gambit's threads to have one thread block on port I/O and
>> allow another thread to check a condition variable to see if there is
>> available data.
> So when the reading thread blocks I can't send data on the
> other thread.

http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php?title=Documentation:Procedure_thread-receive

You should use this interface for inter-thread communications.
And there is an optional timeout parameter for this function, as well
as an optional default value.

That seems to be a perfectly good API for what you are looking to do.

You can even do something like

(define-macro (can-i-haz-mail?)
 `(let ((noes (cons #f #f)))
    (not (eq? noes (thread-mailbox-next -inf.0 noes)))))

that would return #f if you have no mail, and #t if you have some.


Cheers,

P!

-- 
Français, English, 日本語, 한국어



More information about the Gambit-list mailing list