
We have choice-evt
to “logically OR” two or more events; the result is ready when any are. Is replace-evt
how to “logically AND” two events; the result is ready when all are. e.g. (replace-evt e1 (λ (_) e2))
?

(In the special case where you don’t care about the synchronization result value of e1
, just the fact that it was ready. Where you know e1
is an event such as a port, timer, always-evt
, never-evt
, etc.)

I guess the “logical AND” analogy isn’t quite right, due to time and concurrency. But I do mean something weaker — e1
was ready, and subsequently e2
is ready (even if e1
might no longer be).

Yes, replace-evt
is an approximation to “and” in that sense. There’s no stronger “and”, since it would require fundamentally different internal machinery. (It’s a theorem that you can’t get N-way rendezvous from the 1-way rendezvous that is provided by Racket’s event API.)

maybe racket4 needs to implement Aaron Turon’s reagents

Thanks, that’s helpful! I guess that was an XY question. My specific situation is I am working on some flow/congestion control. Reading from the in
of a pipe
. So I wanted to compose in
being ready, with some event which is ready when “not congested”. It took me awhile to figure out that replace-evt
was a way to do this, but I didn’t feel super confident. So I’m glad, it sounds like what I’m doing is not-awful.

Umm, so on 6.10 I’m seeing: Supplying an optional limit to make-pipe
works. It blocks if you try to write more into the pipe without reading. But. Supplying a limit and an optional name to make-pipe
causes it to ignore the limit and accept unlimited writes. For instance: (require rackunit)
(let-values ([(pin pout) (make-pipe 4)])
(write-bytes (make-bytes 4) pout)
(check-false (sync/timeout 0 pout))) ;<- OK
(let-values ([(pin pout) (make-pipe 4 'name)])
(write-bytes (make-bytes 4) pout)
(check-false (sync/timeout 0 pout))) ;<- Nope
I’m guessing this is a bug?

More simply: (let-values ([(pin pout) (make-pipe 4)])
(write-bytes (make-bytes 4) pout)
(sync/timeout 0 pout)) ;=> #f
(let-values ([(pin pout) (make-pipe 4 'name)])
(write-bytes (make-bytes 4) pout)
(sync/timeout 0 pout)) ;=> #<output-port:pipe> WAT

@greg it does the right thing on racketcs

Looks like this ==
check should be a >=
?
https://github.com/racket/racket/blob/master/racket/src/racket/src/portfun.c#L2185

I’m OK sacrificing neat port names if that means I can get back-pressure, now I know have to choose. I was just a very confused person for a very long time, until I saw how to narrow it down.

@jeapostrophe can you actually fix the r-linq package?