-
-
Notifications
You must be signed in to change notification settings - Fork 263
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add FiberHandle module, for holding a reference to a running fiber (#…
- Loading branch information
Showing
11 changed files
with
810 additions
and
117 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
"effect": minor | ||
--- | ||
|
||
close FiberHandle/FiberSet/FiberMap when it is released | ||
|
||
When they are closed, fibers can no longer be added to them. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
--- | ||
"effect": patch | ||
--- | ||
|
||
add FiberMap.has/unsafeHas api |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
--- | ||
"effect": patch | ||
--- | ||
|
||
add FiberHandle module, for holding a reference to a running fiber | ||
|
||
```ts | ||
import { Effect, FiberHandle } from "effect" | ||
|
||
Effect.gen(function* (_) { | ||
const handle = yield* _(FiberHandle.make()) | ||
|
||
// run some effects | ||
yield* _(FiberHandle.run(handle, Effect.never)) | ||
// this will interrupt the previous fiber | ||
yield* _(FiberHandle.run(handle, Effect.never)) | ||
// this will not run, as a fiber is already running | ||
yield* _(FiberHandle.run(handle, Effect.never, { onlyIfMissing: true })) | ||
|
||
yield* _(Effect.sleep(1000)) | ||
}).pipe( | ||
Effect.scoped // The fiber will be interrupted when the scope is closed | ||
) | ||
``` |
Oops, something went wrong.