summaryrefslogtreecommitdiff
path: root/fibers/channels.scm
diff options
context:
space:
mode:
Diffstat (limited to 'fibers/channels.scm')
-rw-r--r--fibers/channels.scm48
1 files changed, 23 insertions, 25 deletions
diff --git a/fibers/channels.scm b/fibers/channels.scm
index c38ac31..7676c37 100644
--- a/fibers/channels.scm
+++ b/fibers/channels.scm
@@ -73,7 +73,7 @@ with a receiver fiber to send @var{message} over @var{channel}."
;; Return #f if the getq was empty.
(and getq*
(match item
- (#(get-flag get-fiber get-wrap-fn)
+ (#(get-flag resume-get get-wrap-fn)
(let spin ()
(match (atomic-box-compare-and-swap! get-flag 'W 'S)
('W
@@ -85,10 +85,10 @@ with a receiver fiber to send @var{message} over @var{channel}."
;; performs any other operation on this
;; channel.
(maybe-commit)
- (resume-fiber get-fiber (if get-wrap-fn
- (lambda ()
- (get-wrap-fn message))
- (lambda () message)))
+ (resume-get (if get-wrap-fn
+ (lambda ()
+ (get-wrap-fn message))
+ (lambda () message)))
;; Continue directly.
(lambda () (values)))
;; Get operation temporarily busy; try again.
@@ -99,16 +99,16 @@ with a receiver fiber to send @var{message} over @var{channel}."
;; try again next time if no other fiber
;; handled it already.
('S (try (maybe-commit))))))))))))
- (define (block-fn put-flag put-fiber put-wrap-fn)
+ (define (block-fn put-flag put-sched resume-put put-wrap-fn)
;; We have suspended the current fiber; arrange for the fiber
;; to be resumed by a get operation by adding it to the channel's
;; putq.
(define (not-me? item)
(match item
- (#(get-flag get-fiber get-wrap-fn)
+ (#(get-flag resume-get get-wrap-fn)
(not (eq? put-flag get-flag)))))
;; First, publish this put operation.
- (enqueue! putq-box (vector put-flag put-fiber put-wrap-fn message))
+ (enqueue! putq-box (vector put-flag resume-put put-wrap-fn message))
;; In the try phase, we scanned the getq for a get operation,
;; but we were unable to perform any of them. Since then,
;; there might be a new get operation on the queue. However
@@ -131,7 +131,7 @@ with a receiver fiber to send @var{message} over @var{channel}."
;; We only have to service the getq if it is non-empty.
(when getq*
(match item
- (#(get-flag get-fiber get-wrap-fn)
+ (#(get-flag resume-get get-wrap-fn)
(match (atomic-box-ref get-flag)
('S
;; This get operation has already synchronized;
@@ -151,11 +151,10 @@ with a receiver fiber to send @var{message} over @var{channel}."
;; getq, and resume both fibers.
(atomic-box-set! put-flag 'S)
(maybe-commit)
- (resume-fiber get-fiber
- (if get-wrap-fn
- (lambda () (get-wrap-fn message))
- (lambda () message)))
- (resume-fiber put-fiber (or put-wrap-fn values))
+ (resume-get (if get-wrap-fn
+ (lambda () (get-wrap-fn message))
+ (lambda () message)))
+ (resume-put (or put-wrap-fn values))
(values))
('C
;; Other fiber trying to do the same
@@ -196,7 +195,7 @@ with a sender fiber to receive one value from @var{channel}."
;; Return #f if the putq was empty.
(and putq*
(match item
- (#(put-flag put-fiber put-wrap-fn message)
+ (#(put-flag resume-put put-wrap-fn message)
(let spin ()
(match (atomic-box-compare-and-swap! put-flag 'W 'S)
('W
@@ -206,7 +205,7 @@ with a sender fiber to receive one value from @var{channel}."
;; it before synchronizing any other
;; operation on this channel.
(maybe-commit)
- (resume-fiber put-fiber (or put-wrap-fn values))
+ (resume-put (or put-wrap-fn values))
;; Continue directly.
(lambda () message))
;; Put operation temporarily busy; try again.
@@ -217,16 +216,16 @@ with a sender fiber to receive one value from @var{channel}."
;; try again next time if no other fiber
;; handled it already.
('S (try (maybe-commit))))))))))))
- (define (block-fn get-flag get-fiber get-wrap-fn)
+ (define (block-fn get-flag get-sched resume-get get-wrap-fn)
;; We have suspended the current fiber; arrange for the fiber
;; to be resumed by a put operation by adding it to the
;; channel's getq.
(define (not-me? item)
(match item
- (#(put-flag put-fiber put-wrap-fn message)
+ (#(put-flag resume-put put-wrap-fn message)
(not (eq? get-flag put-flag)))))
;; First, publish this get operation.
- (enqueue! getq-box (vector get-flag get-fiber get-wrap-fn))
+ (enqueue! getq-box (vector get-flag resume-get get-wrap-fn))
;; In the try phase, we scanned the putq for a live put
;; operation, but we were unable to synchronize. Since then,
;; there might be a new operation on the putq. However only
@@ -249,7 +248,7 @@ with a sender fiber to receive one value from @var{channel}."
;; We only have to service the putq if it is non-empty.
(when putq*
(match item
- (#(put-flag put-fiber put-wrap-fn message)
+ (#(put-flag resume-put put-wrap-fn message)
(match (atomic-box-ref put-flag)
('S
;; This put operation has already synchronized;
@@ -270,11 +269,10 @@ with a sender fiber to receive one value from @var{channel}."
;; fibers for resumption.
(atomic-box-set! get-flag 'S)
(maybe-commit)
- (resume-fiber get-fiber
- (if get-wrap-fn
- (lambda () (get-wrap-fn message))
- (lambda () message)))
- (resume-fiber put-fiber (or put-wrap-fn values))
+ (resume-get (if get-wrap-fn
+ (lambda () (get-wrap-fn message))
+ (lambda () message)))
+ (resume-put (or put-wrap-fn values))
(values))
('C
;; Other fiber trying to do the same