// Type aliases — re-export all types from internal/types
///|
pub type ThreadId = @types.ThreadId
///|
pub type EntryId = @types.EntryId
///|
pub type StartArg = @types.StartArg
///|
pub type SharedMemoryId = @types.SharedMemoryId
///|
pub type AtomicOffset = @types.AtomicOffset
///|
pub type ThreadBackendKind = @types.ThreadBackendKind
///|
pub type ThreadError = @types.ThreadError
///|
pub type WaitResult = @types.WaitResult
///|
pub type WaitCallerContext = @types.WaitCallerContext
///|
pub type SpawnOptions = @types.SpawnOptions
///|
pub type SpawnSpec = @types.SpawnSpec
///|
pub type SharedMemory = @types.SharedMemory
///|
pub type AtomicI32Ref = @types.AtomicI32Ref
///|
pub type MutexRef = @types.MutexRef
///|
pub type ThreadOps = @types.ThreadOps
///|
pub type AtomicOps = @types.AtomicOps
///|
pub type MutexOps = @types.MutexOps
///|
pub type PlatformCapabilities = @types.PlatformCapabilities
///|
pub type MultithreadPlatform = @types.MultithreadPlatform
///|
pub type RegisteredEntry = @types.RegisteredEntry
// Function wrappers — re-export all pub functions from internal/types
///|
pub fn backend_native() -> ThreadBackendKind {
@types.backend_native()
}
///|
pub fn backend_node_worker() -> ThreadBackendKind {
@types.backend_node_worker()
}
///|
pub fn backend_web_worker() -> ThreadBackendKind {
@types.backend_web_worker()
}
///|
pub fn backend_wasi_threads() -> ThreadBackendKind {
@types.backend_wasi_threads()
}
///|
pub fn thread_error_resource_exhausted() -> ThreadError {
@types.thread_error_resource_exhausted()
}
///|
pub fn thread_error_host_failure(message : String) -> ThreadError {
@types.thread_error_host_failure(message)
}
///|
pub fn wait_ok() -> WaitResult {
@types.wait_ok()
}
///|
pub fn wait_not_equal() -> WaitResult {
@types.wait_not_equal()
}
///|
pub fn wait_timed_out() -> WaitResult {
@types.wait_timed_out()
}
///|
pub fn wait_caller_main_thread() -> WaitCallerContext {
@types.wait_caller_main_thread()
}
///|
pub fn wait_caller_worker_thread() -> WaitCallerContext {
@types.wait_caller_worker_thread()
}
///|
pub fn spawn_options(
detached? : Bool = false,
stack_size? : Int,
name? : String,
) -> SpawnOptions {
@types.spawn_options(detached~, stack_size?, name?)
}
///|
pub fn spawn_spec(
entry_id : EntryId,
start_arg : StartArg,
options? : SpawnOptions = spawn_options(),
) -> SpawnSpec {
@types.spawn_spec(entry_id, start_arg, options~)
}
///|
pub fn spawn_spec_registered(
entry : RegisteredEntry,
start_arg : StartArg,
options? : SpawnOptions = spawn_options(),
) -> SpawnSpec {
@types.spawn_spec_registered(entry, start_arg, options~)
}
///|
pub fn shared_memory(
memory_id : SharedMemoryId,
byte_length : Int,
) -> Result[SharedMemory, ThreadError] {
@types.shared_memory(memory_id, byte_length)
}
///|
pub fn atomic_i32(
memory : SharedMemory,
offset : AtomicOffset,
) -> Result[AtomicI32Ref, ThreadError] {
@types.atomic_i32(memory, offset)
}
///|
pub fn mutex_ref(state : AtomicI32Ref) -> MutexRef {
@types.mutex_ref(state)
}
///|
pub fn thread_ops(
spawn : (SpawnSpec) -> Result[ThreadId, ThreadError],
join : (ThreadId) -> Result[Int, ThreadError],
try_join : (ThreadId) -> Result[Int?, ThreadError],
detach : (ThreadId) -> Result[Unit, ThreadError],
current_thread_id : () -> ThreadId,
) -> ThreadOps {
@types.thread_ops(spawn, join, try_join, detach, current_thread_id)
}
///|
pub fn thread_ops_unsupported() -> ThreadOps {
@types.thread_ops_unsupported()
}
///|
pub fn atomic_ops_unsupported() -> AtomicOps {
@types.atomic_ops_unsupported()
}
///|
pub fn mutex_ops_unsupported() -> MutexOps {
@types.mutex_ops_unsupported()
}
///|
pub fn platform_capabilities(
supports_join? : Bool = true,
supports_detach? : Bool = true,
supports_wait_timeout? : Bool = true,
supports_blocking_wait_on_main_thread? : Bool = true,
) -> PlatformCapabilities {
@types.platform_capabilities(
supports_join~,
supports_detach~,
supports_wait_timeout~,
supports_blocking_wait_on_main_thread~,
)
}
///|
pub fn native_capabilities() -> PlatformCapabilities {
@types.native_capabilities()
}
///|
pub fn node_worker_capabilities() -> PlatformCapabilities {
@types.node_worker_capabilities()
}
///|
pub fn web_worker_capabilities() -> PlatformCapabilities {
@types.web_worker_capabilities()
}
///|
pub fn wasi_threads_capabilities() -> PlatformCapabilities {
@types.wasi_threads_capabilities()
}
///|
pub fn default_capabilities_for_backend(
backend_kind : ThreadBackendKind,
) -> PlatformCapabilities {
@types.default_capabilities_for_backend(backend_kind)
}
///|
pub fn multithread_platform(
backend_kind : ThreadBackendKind,
thread : ThreadOps,
atomics : AtomicOps,
mutex : MutexOps,
capabilities? : PlatformCapabilities = default_capabilities_for_backend(
backend_kind,
),
) -> MultithreadPlatform {
@types.multithread_platform(
backend_kind,
thread,
atomics,
mutex,
capabilities~,
)
}
///|
pub fn multithread_platform_unsupported(
backend_kind? : ThreadBackendKind = @types.BackendWasiThreads,
) -> MultithreadPlatform {
@types.multithread_platform_unsupported(backend_kind~)
}
///|
pub async fn thread_join_async(
platform : MultithreadPlatform,
thread_id : ThreadId,
poll_interval_ms? : Int = 1,
) -> Result[Int, ThreadError] {
@types.thread_join_async(platform, thread_id, poll_interval_ms~)
}
///|
pub fn thread_join(
platform : MultithreadPlatform,
thread_id : ThreadId,
) -> Result[Int, ThreadError] {
@types.thread_join(platform, thread_id)
}
///|
pub fn thread_detach(
platform : MultithreadPlatform,
thread_id : ThreadId,
) -> Result[Unit, ThreadError] {
@types.thread_detach(platform, thread_id)
}
///|
pub fn atomic_wait_i32(
platform : MultithreadPlatform,
addr : AtomicI32Ref,
expect : Int,
timeout_ns? : Int64,
caller_context? : WaitCallerContext = @types.CallerWorkerThread,
) -> Result[WaitResult, ThreadError] {
@types.atomic_wait_i32(platform, addr, expect, timeout_ns?, caller_context~)
}
///|
pub fn registered_entry_passthrough() -> RegisteredEntry {
@types.registered_entry_passthrough()
}
///|
pub fn registered_entry_increment() -> RegisteredEntry {
@types.registered_entry_increment()
}
///|
pub fn registered_entry_double() -> RegisteredEntry {
@types.registered_entry_double()
}
///|
pub fn registered_entry_shared_counter_add() -> RegisteredEntry {
@types.registered_entry_shared_counter_add()
}
///|
pub fn registered_entry_shared_counter_mutex() -> RegisteredEntry {
@types.registered_entry_shared_counter_mutex()
}
///|
pub fn registered_entry_to_id(entry : RegisteredEntry) -> EntryId {
@types.registered_entry_to_id(entry)
}
///|
pub fn registered_entry_from_id(entry_id : EntryId) -> RegisteredEntry? {
@types.registered_entry_from_id(entry_id)
}
// Function wrappers — re-export pub functions from internal/backend
///|
pub fn multithread_platform_for_backend(
backend_kind : ThreadBackendKind,
) -> MultithreadPlatform {
@backend.multithread_platform_for_backend(backend_kind)
}
///|
pub fn multithread_platform_auto() -> MultithreadPlatform {
@backend.multithread_platform_auto()
}
///|
pub async fn thread_join_portable(
platform : MultithreadPlatform,
thread_id : ThreadId,
poll_interval_ms? : Int = 1,
) -> Result[Int, ThreadError] {
@backend.thread_join_portable(platform, thread_id, poll_interval_ms~)
}
///|
pub async fn thread_spawn_join_portable(
platform : MultithreadPlatform,
spec : SpawnSpec,
poll_interval_ms? : Int = 1,
) -> Result[Int, ThreadError] {
@backend.thread_spawn_join_portable(platform, spec, poll_interval_ms~)
}
///|
pub fn multithread_platform_native_c() -> MultithreadPlatform {
@backend.multithread_platform_native_c()
}
///|
pub fn multithread_platform_node_worker() -> MultithreadPlatform {
@backend.multithread_platform_node_worker()
}
///|
pub fn multithread_platform_web_worker() -> MultithreadPlatform {
@backend.multithread_platform_web_worker()
}
///|
pub fn multithread_platform_wasi_threads() -> MultithreadPlatform {
@backend.multithread_platform_wasi_threads()
}