diff options
| author | Andy Wingo <wingo@pobox.com> | 2017-01-08 17:17:42 +0100 |
|---|---|---|
| committer | Andy Wingo <wingo@pobox.com> | 2017-01-08 17:17:42 +0100 |
| commit | 8aa6ac0a6c6a86492d3f351a312d264216fbd2e5 (patch) | |
| tree | 91f1b967f80f3b0236535300ba5a2f3656ca560f /fibers | |
| parent | Enable preemption by default (diff) | |
| download | guile-fibers-8aa6ac0a6c6a86492d3f351a312d264216fbd2e5.tar.gz | |
create-fiber always captures dynamic state
* fibers/internal.scm (create-fiber): Remove dynamic-state argument;
always capture the current dynamic state.
* fibers/timers.scm (timer-operation):
* fibers.scm (spawn-fiber): Adapt.
Diffstat (limited to 'fibers')
| -rw-r--r-- | fibers/internal.scm | 19 | ||||
| -rw-r--r-- | fibers/timers.scm | 3 |
2 files changed, 11 insertions, 11 deletions
diff --git a/fibers/internal.scm b/fibers/internal.scm index c4d75a6..99727f6 100644 --- a/fibers/internal.scm +++ b/fibers/internal.scm @@ -333,17 +333,18 @@ stolen." (for-each kill-fiber (list-copy (scheduler-fibers sched))) (epoll-destroy (scheduler-epfd sched))) -(define (create-fiber sched thunk dynamic-state) +(define (create-fiber sched thunk) "Spawn a new fiber in @var{sched} with the continuation @var{thunk}. -The fiber will be scheduled on the next turn. During the fiber's -extent, @var{dynamic-state} will be made current, isolating fluid and -parameter mutations to this fiber." +The fiber will be scheduled on the next turn. @var{thunk} will run +with a copy of the current dynamic state, isolating fluid and +parameter mutations to the fiber." (let* ((fiber (make-fiber sched #f)) - (thunk (lambda () - (with-dynamic-state dynamic-state - (lambda () - (current-fiber fiber) - (thunk)))))) + (thunk (let ((dynamic-state (current-dynamic-state))) + (lambda () + (with-dynamic-state dynamic-state + (lambda () + (current-fiber fiber) + (thunk))))))) (nameset-add! fibers-nameset fiber) (schedule-fiber! fiber thunk))) diff --git a/fibers/timers.scm b/fibers/timers.scm index 15638b0..1ccd088 100644 --- a/fibers/timers.scm +++ b/fibers/timers.scm @@ -61,8 +61,7 @@ units. The operation will succeed with no values." (create-fiber (timer-sched) (lambda () (perform-operation (timer-operation expiry)) - (timer)) - (current-dynamic-state)))))) + (timer))))))) (define (wait-operation seconds) "Make an operation that will succeed with no values when |
