diff --git a/src/cond_var/cond_var.mbt b/src/cond_var/cond_var.mbt index 4de58309..c3d09b19 100644 --- a/src/cond_var/cond_var.mbt +++ b/src/cond_var/cond_var.mbt @@ -30,6 +30,7 @@ priv struct Waiter { ///| /// A condition variable that can be used for synchronization between tasks. +#valtype struct Cond { waiters : @deque.Deque[Waiter] } diff --git a/src/internal/coroutine/coroutine.mbt b/src/internal/coroutine/coroutine.mbt index 64f9832a..33994480 100644 --- a/src/internal/coroutine/coroutine.mbt +++ b/src/internal/coroutine/coroutine.mbt @@ -13,7 +13,7 @@ // limitations under the License. ///| -priv enum State { +enum State { Done Fail(Error) Running @@ -21,7 +21,7 @@ priv enum State { } ///| -struct Coroutine { +pub struct Coroutine { coro_id : Int mut state : State mut shielded : Bool diff --git a/src/internal/coroutine/pkg.generated.mbti b/src/internal/coroutine/pkg.generated.mbti index 5b50dcd2..2aa8e2a6 100644 --- a/src/internal/coroutine/pkg.generated.mbti +++ b/src/internal/coroutine/pkg.generated.mbti @@ -3,6 +3,7 @@ package "moonbitlang/async/internal/coroutine" import { "moonbitlang/core/debug", + "moonbitlang/core/set", } // Values @@ -32,7 +33,14 @@ pub(all) suberror Cancelled derive(@debug.Debug) pub impl Show for Cancelled // Types and methods -type Coroutine +pub struct Coroutine { + coro_id : Int + mut state : State + mut shielded : Bool + mut cancelled : Bool + mut ready : Bool + downstream : @set.Set[Coroutine] +} pub fn Coroutine::cancel(Self) -> Unit pub fn Coroutine::check_error(Self) -> Unit raise pub fn Coroutine::unwrap(Self) -> Unit raise @@ -41,6 +49,8 @@ pub fn Coroutine::wake(Self) -> Unit pub impl Eq for Coroutine pub impl Hash for Coroutine +type State + // Type aliases // Traits diff --git a/src/task.mbt b/src/task.mbt index c83282fb..48f90cc1 100644 --- a/src/task.mbt +++ b/src/task.mbt @@ -15,6 +15,7 @@ ///| /// `Task[X]` represents a running task with result type `X`, /// it can be used to wait and retrieve the result value of the task. +#valtype struct Task[X] { value : Ref[X?] coro : @coroutine.Coroutine