import * as Schema from "../Schema.ts"; /** * The typed arrays that can live in shared memory. * * @stability unstable * @category models * @since 4.1.5 */ export type TypedArray = Int8Array | Uint8Array | Uint8ClampedArray | Int16Array | Uint16Array | Int32Array | Uint32Array | Float32Array | Float64Array | BigInt64Array | BigUint64Array; /** * The constructors of {@link TypedArray}s. * * @stability unstable * @category models * @since 4.1.5 */ export type TypedArrayConstructor = Int8ArrayConstructor | Uint8ArrayConstructor | Uint8ClampedArrayConstructor | Int16ArrayConstructor | Uint16ArrayConstructor | Int32ArrayConstructor | Uint32ArrayConstructor | Float32ArrayConstructor | Float64ArrayConstructor | BigInt64ArrayConstructor | BigUint64ArrayConstructor; interface SharedByName { readonly Int8Array: Int8Array; readonly Uint8Array: Uint8Array; readonly Uint8ClampedArray: Uint8ClampedArray; readonly Int16Array: Int16Array; readonly Uint16Array: Uint16Array; readonly Int32Array: Int32Array; readonly Uint32Array: Uint32Array; readonly Float32Array: Float32Array; readonly Float64Array: Float64Array; readonly BigInt64Array: BigInt64Array; readonly BigUint64Array: BigUint64Array; } /** * The kind of typed array `A`, backed by a `SharedArrayBuffer`. * * @stability unstable * @category models * @since 4.1.5 */ export type Shared = SharedByName[A[typeof Symbol.toStringTag]]; declare const SharedMemoryError_base: new = {}>(args: import("../Types.ts").VoidIfEmpty<{ readonly [P in keyof A as P extends "_tag" ? never : P]: A[P]; }>) => import("../Cause.ts").YieldableError & { readonly _tag: "SharedMemoryError"; } & Readonly; /** * Thrown by {@link make} when shared memory is unavailable. * * @see {@link isAvailable} Check availability before allocating. * * @stability unstable * @category errors * @since 4.1.5 */ export declare class SharedMemoryError extends SharedMemoryError_base<{ readonly message: string; }> { } /** * Returns whether shared memory is available in this environment. * * **Details** * * True in Node, Bun and Deno. In browsers, true only on a cross-origin * isolated page (`crossOriginIsolated`). * * @stability unstable * @category guards * @since 4.1.5 */ export declare const isAvailable: () => boolean; /** * Returns whether the view's memory is a `SharedArrayBuffer`. * * @stability unstable * @category guards * @since 4.1.5 */ export declare const isShared: (view: ArrayBufferView) => boolean; /** * Allocates a zero-filled typed array of `length` elements in shared memory. * * **Gotchas** * * Throws {@link SharedMemoryError} when shared memory is unavailable. * * **Example** (Copying existing values into shared memory) * * ```ts import.meta.vitest * import { SharedMemory } from "effect/workers" * * const values = Int32Array.of(1, 2, 3) * const shared = SharedMemory.make(Int32Array, values.length) * shared.set(values) * values[0] = 9 * shared[0] // => 1 * ``` * * @stability unstable * @category constructors * @since 4.1.5 */ export declare const make: (constructor: C, length: number) => Shared>; /** * Creates a worker-message schema for a typed array backed by shared memory. * * **Details** * * - Decoding and encoding accept only instances of `constructor` backed by * a `SharedArrayBuffer`. Serialized copies fail validation. * - `Schema.toCodecJson` passes the array through unchanged for `postMessage`. * * @stability unstable * @category schemas * @since 4.1.5 */ export declare const schema: (constructor: C) => Schema.declare>>; export {}; //# sourceMappingURL=SharedMemory.d.ts.map