Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 12 additions & 0 deletions src/lazy_init.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,18 @@ pub async fn[X] Lazy::wait(self : Lazy[X]) -> X {
}
}

///|
/// Return the result of a lazy value if is already computed,
/// or return `None` if the result is not immediately available.
/// Fail with the same error if the initialization process failed.
pub fn[X] Lazy::try_wait(self : Lazy[X]) -> X? raise {
match self.state {
Done(result) => Some(result)
Fail(err) => raise err
Running(_) | Uninitialized => None
}
}

///|
/// Create a new lazily initialized value by passing an async initialization function.
/// The function `f` will be started in the background automatically
Expand Down
3 changes: 3 additions & 0 deletions src/os_error/errno_linux.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ let linux_EINPROGRESS : Int = 115

///|
let linux_EWOULDBLOCK : Int = linux_EAGAIN

///|
let linux_EPIPE : Int = 32
3 changes: 3 additions & 0 deletions src/os_error/errno_macos.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -41,3 +41,6 @@ let macos_EINPROGRESS : Int = 36

///|
let macos_EWOULDBLOCK : Int = macos_EAGAIN

///|
let macos_EPIPE : Int = 32
3 changes: 3 additions & 0 deletions src/os_error/errno_windows.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -44,3 +44,6 @@ let windows_ERROR_DIRECTORY : Int = 267

///|
let windows_ERROR_NOT_SUPPORTED : Int = 50

///|
let windows_ERROR_BROKEN_PIPE : Int = 109
7 changes: 7 additions & 0 deletions src/os_error/error.mbt
Original file line number Diff line number Diff line change
Expand Up @@ -182,3 +182,10 @@ pub let errno_ENOTSUP : Int = match @env_util.platform {
MacOS => macos_ENOTSUP
Windows => windows_ERROR_NOT_SUPPORTED
}

///|
pub let errno_EPIPE : Int = match @env_util.platform {
Linux => linux_EPIPE
MacOS => macos_EPIPE
Windows => windows_ERROR_BROKEN_PIPE
}
2 changes: 2 additions & 0 deletions src/os_error/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@ pub let errno_ENOTDIR : Int

pub let errno_ENOTSUP : Int

pub let errno_EPIPE : Int

pub fn errno_to_string(Int) -> String

pub fn get_errno() -> Int
Expand Down
1 change: 1 addition & 0 deletions src/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ type Lazy[X]
#as_free_fn(lazy_init, deprecated)
#callsite(autofill(loc))
pub fn[X] Lazy::Lazy(async () -> X, loc~ : SourceLoc) -> Self[X]
pub fn[X] Lazy::try_wait(Self[X]) -> X? raise
pub async fn[X] Lazy::wait(Self[X]) -> X

type Mutex
Expand Down
10 changes: 5 additions & 5 deletions src/process/pkg.generated.mbti
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@ pub fn graceful_cancel(timeout~ : Int, signal? : @signal.Signal) -> Cancellation

pub fn hard_cancel() -> CancellationHandler

pub fn pipe() -> (&ProcessInput, &ProcessOutput) raise
pub fn pipe() -> (&ProcessInput, &ProcessOutput)

pub fn read_from_process(shared? : Bool) -> (ReadFromProcess, &ProcessOutput) raise
pub fn read_from_process(shared? : Bool) -> (ReadFromProcess, &ProcessOutput)

pub async fn redirect_from_file(String) -> &ProcessInput
pub fn redirect_from_file(String) -> &ProcessInput

pub async fn redirect_to_file(String, append? : Bool, create_mode? : @fs.CreateMode, permission? : Int, shared? : Bool) -> &ProcessOutput
pub fn redirect_to_file(String, append? : Bool, create_mode? : @fs.CreateMode, permission? : Int, shared? : Bool) -> &ProcessOutput

pub async fn run(StringView, ArrayView[String], extra_env? : Map[String, String], inherit_env? : Bool, stdin? : &ProcessInput, stdout? : &ProcessOutput, stderr? : &ProcessOutput, cwd? : StringView, no_console_window? : Bool, cancel_handler? : CancellationHandler) -> Int

Expand All @@ -39,7 +39,7 @@ pub async fn spawn_orphan(StringView, ArrayView[String], extra_env? : Map[String

pub async fn wait_pid(Int) -> Int

pub fn write_to_process() -> (&ProcessInput, WriteToProcess) raise
pub fn write_to_process() -> (&ProcessInput, WriteToProcess)

// Errors

Expand Down
Loading
Loading