Datatype · Userdata

WriteLoop

userdata

Stateful write-loop returned by memory.create_write_loop. Holds an address and a payload buffer and writes that buffer to the address repeatedly from a background thread, sidestepping Luau VM overhead. Default cadence is a tight loop (interval_us = 0); throttle via set_interval_us. The loop is created stopped and must be started with start(). The buffer can be swapped at any time without recreating the loop. mode is "shared" (default: one background worker shared by every Shared loop) or "exclusive" (a thread dedicated to this loop). After destroy() the proxy becomes inert.

Fields

NameTypeDescription
destroy() -> ()

Stops the loop, releases the buffer, and detaches the proxy from the service. Subsequent method calls become no-ops.

get_address() -> number

Current target address.

get_buffer() -> buffer

Returns a fresh buffer copy of the current payload.

get_interval_us() -> number

Current interval in microseconds.

get_last_result() -> ProcessWriteResult

ProcessWriteResult value of the most recent write attempt.

get_mode() -> string

Returns "shared" or "exclusive". Fixed at creation.

get_write_count() -> number

Total successful writes since creation. Diagnostic.

is_running() -> boolean

Snapshot of the live running state.

set_address(address: number) -> ()

Atomically swaps the target address.

set_buffer(buffer: buffer) -> ()

Atomically swaps the payload buffer. The next write picks up the new bytes; in-flight writes complete with the previous buffer.

set_interval_us(microseconds: number) -> ()

Sleep between writes in microseconds. 0 (default) means tight-loop with no sleep. Negative values are clamped to 0.

start() -> ()

Begins the loop. No-op when already running or destroyed.

stop() -> ()

Stops the loop. The worker honours this on its next tick. State is preserved; start() resumes.