diff options
| author | Andy Wingo <wingo@pobox.com> | 2017-02-14 22:20:59 +0100 |
|---|---|---|
| committer | Andy Wingo <wingo@pobox.com> | 2017-02-14 22:20:59 +0100 |
| commit | 7993e229f918ae23934dfd663fc91123c96cc97c (patch) | |
| tree | 0c8e74721c58e4d35d5573bbb471a122f5b13a8e /examples | |
| parent | Fix spurious epoll traffic (diff) | |
| download | guile-fibers-7993e229f918ae23934dfd663fc91123c96cc97c.tar.gz | |
Fix ping-client
* examples/ping-client.scm: Fix for run-fibers changes, to only exit
when done.
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/ping-client.scm | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/examples/ping-client.scm b/examples/ping-client.scm index afbfd0d..b2b3db2 100644 --- a/examples/ping-client.scm +++ b/examples/ping-client.scm @@ -19,6 +19,7 @@ (use-modules (rnrs bytevectors) (fibers) + (fibers channels) (ice-9 binary-ports) (ice-9 textual-ports) (ice-9 rdelim) @@ -57,12 +58,15 @@ ;; The getaddrinfo call blocks, unfortunately. Call it once before ;; spawning clients. (let ((addrinfo (car (getaddrinfo "localhost" (number->string 11211))))) - (let lp ((n 0)) - (when (< n num-clients) - (spawn-fiber - (lambda () - (client-loop addrinfo n num-connections))) - (lp (1+ n)))))) + (map get-message + (map (lambda (n) + (let ((ch (make-channel))) + (spawn-fiber + (lambda () + (client-loop addrinfo n num-connections) + (put-message ch 'done))) + ch)) + (iota num-clients))))) (run-fibers (lambda () |
