I currently spawn a thread for reading data but on the other thread I send data. So when the reading thread blocks I can't send data on the other thread.
-Sean Chapel
On Tue, Dec 28, 2010 at 5:26 PM, Frederick LeMaster fred.lemaster@gmail.com wrote:
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.
2010/12/28 sean chapel seoushi@gmail.com:
P!,
Thanks. I did see that function but it's not quite what I was looking for but it should work. I would have to set the timeout to 0 so it returns instantly. Something like c's poll function would be a better fit.
-Sean Chapel
2010/12/28 Adrien "Pied" Piérard axioplase@gmail.com:
Hi.
I tried using "peek-char" but it seems it's blocking. What should I use in this situation?
I'm pretty sure you're looking for INPUT-PORT-TIMEOUT-SET! http://dynamo.iro.umontreal.ca/~gambit/wiki/index.php?title=Documentation:Pr...
Cheers,
P!
Français, English, 日本語, 한국어
Gambit-list mailing list Gambit-list@iro.umontreal.ca https://webmail.iro.umontreal.ca/mailman/listinfo/gambit-list
Afficher les réponses par date
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:Pr...
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!