greg
2018-12-17 15:09:45

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)) ?


greg
2018-12-17 15:29:47

(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.)


greg
2018-12-17 15:33:11

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).


mflatt
2018-12-17 15:46:04

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.)


samth
2018-12-17 15:52:44

maybe racket4 needs to implement Aaron Turon’s reagents


greg
2018-12-17 17:57:11

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.


greg
2018-12-17 22:17:28

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?


greg
2018-12-17 22:22:12

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


samth
2018-12-17 22:24:50

@greg it does the right thing on racketcs


florence
2018-12-17 22:25:07

greg
2018-12-17 22:44:07

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.


samth
2018-12-18 03:39:27

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