diff options
author | Maxime Devos <maximedevos@telenet.be> | 2021-09-01 20:08:05 +0200 |
---|---|---|
committer | Maxime Devos <maximedevos@telenet.be> | 2021-09-21 12:20:55 +0200 |
commit | b8183f5894602fd8f848dc8be9772608fc97a647 (patch) | |
tree | 2066cf9518697e78cc4eccbf315cc838622172b5 /gnu | |
parent | 3dccfcbdc7a7b8a14b202918fd73b29df6e96c87 (diff) | |
download | gnunet-scheme-b8183f5894602fd8f848dc8be9772608fc97a647.tar.gz gnunet-scheme-b8183f5894602fd8f848dc8be9772608fc97a647.zip |
mq-impl/stream: Delay knowing the port.
* gnu/gnunet/mq-impl/stream.scm
(prepare-port-message-queue): Remove 'port' argument.
(prepare-port-message-queue)[start-reader!,start-writer!]:
Add 'port' argument'
(port->message-queue): Adjust caller.
Diffstat (limited to 'gnu')
-rw-r--r-- | gnu/gnunet/mq-impl/stream.scm | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/gnu/gnunet/mq-impl/stream.scm b/gnu/gnunet/mq-impl/stream.scm index 3a34c37..bcee0b0 100644 --- a/gnu/gnunet/mq-impl/stream.scm +++ b/gnu/gnunet/mq-impl/stream.scm | |||
@@ -260,7 +260,7 @@ an appropriate @code{&undefined-key-error} is raised." | |||
260 | (retry)))) | 260 | (retry)))) |
261 | 261 | ||
262 | ;; See 'port->message-queue'. Also used by connect/fibers. | 262 | ;; See 'port->message-queue'. Also used by connect/fibers. |
263 | (define* (prepare-port-message-queue port spawn) | 263 | (define* (prepare-port-message-queue spawn) |
264 | ;; TODO: closing message queues | 264 | ;; TODO: closing message queues |
265 | (define rcvar (make-repeated-condition)) | 265 | (define rcvar (make-repeated-condition)) |
266 | (define (interrupt! mq) | 266 | (define (interrupt! mq) |
@@ -270,7 +270,7 @@ an appropriate @code{&undefined-key-error} is raised." | |||
270 | ;; it informs the other fiber by signalling the condition and injects | 270 | ;; it informs the other fiber by signalling the condition and injects |
271 | ;; an appropriate error, unless the other fiber will do it already. | 271 | ;; an appropriate error, unless the other fiber will do it already. |
272 | (define closed-condition (make-condition)) | 272 | (define closed-condition (make-condition)) |
273 | (define (start-reader! mq) | 273 | (define (start-reader! mq port) |
274 | (define-values (key . rest) | 274 | (define-values (key . rest) |
275 | (let/ec escape | 275 | (let/ec escape |
276 | (define wait-op | 276 | (define wait-op |
@@ -289,7 +289,7 @@ an appropriate @code{&undefined-key-error} is raised." | |||
289 | (handle-input! mq port #:return values)))) | 289 | (handle-input! mq port #:return values)))) |
290 | (when (signal-condition! closed-condition) | 290 | (when (signal-condition! closed-condition) |
291 | (apply inject-error! mq key rest))) | 291 | (apply inject-error! mq key rest))) |
292 | (define (start-writer! mq) | 292 | (define (start-writer! mq port) |
293 | (let/ec escape | 293 | (let/ec escape |
294 | ;; operation for calling the escape continuation when | 294 | ;; operation for calling the escape continuation when |
295 | ;; when the other fiber detected the connection is broken | 295 | ;; when the other fiber detected the connection is broken |
@@ -328,9 +328,9 @@ an appropriate @code{&undefined-key-error} is raised." | |||
328 | (handle-output! mq port wait!))) | 328 | (handle-output! mq port wait!))) |
329 | (when (signal-condition! closed-condition) | 329 | (when (signal-condition! closed-condition) |
330 | (inject-error! mq 'input:regular-end-of-file))) | 330 | (inject-error! mq 'input:regular-end-of-file))) |
331 | (values (lambda (mq) | 331 | (values (lambda (mq port) |
332 | (spawn (lambda () (start-reader! mq))) | 332 | (spawn (lambda () (start-reader! mq port))) |
333 | (spawn (lambda () (start-writer! mq)))) | 333 | (spawn (lambda () (start-writer! mq port)))) |
334 | ;; Pass this to make-message-queue as the 'sender'. | 334 | ;; Pass this to make-message-queue as the 'sender'. |
335 | interrupt!)) | 335 | interrupt!)) |
336 | 336 | ||
@@ -347,10 +347,10 @@ is injected. A half-duplex port is treated as a broken connection. | |||
347 | XXX: half-duplex connections cannot always be detected | 347 | XXX: half-duplex connections cannot always be detected |
348 | XXX: Likewise for connect/fibers?" | 348 | XXX: Likewise for connect/fibers?" |
349 | (define-values (start-fibers interrupt!) | 349 | (define-values (start-fibers interrupt!) |
350 | (prepare-port-message-queue port spawn)) | 350 | (prepare-port-message-queue spawn)) |
351 | (define mq | 351 | (define mq |
352 | (make-message-queue handlers error-handler interrupt!)) | 352 | (make-message-queue handlers error-handler interrupt!)) |
353 | (start-fibers mq) | 353 | (start-fibers mq port) |
354 | mq) | 354 | mq) |
355 | 355 | ||
356 | (define* (connect/fibers config service-name handlers error-handler | 356 | (define* (connect/fibers config service-name handlers error-handler |