NativeWorker class final

The isolate that runs every call into one native library, alive while a database of that library is open.

Why an isolate: a native call blocks its thread until LMDB answers (a durable commit waits for the disk). Running them here keeps the caller's isolate — the UI, in an app — free. Requests are served in order and matched to their replies by id.

Why it stops: its reply port, open in the caller's isolate, would keep a program alive forever after its last database closed (a CLI that never ends), and the isolate would stay in memory in an app that keeps running. When the last handle is closed and no call is pending, it closes that port and ends the isolate; the next open starts a new worker.

Properties

hashCode → int
The hash code for this object.
no setterinherited
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited

Methods

close(int handle) → Future<Result<String, DbError>>
Releases handle.
execute(int handle, String request) → Future<Result<String, DbError>>
Runs one JSON request of the protocol on handle.
keyValue(int handle, KeyValueCall call, String? argument) → Future<Result<String, DbError>>
Runs one key-value call on handle.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
inherited

Operators

operator ==(Object other) → bool
The equality operator.
inherited

Static Methods

of(NativeSymbols symbols) → Future<NativeWorker>
The running worker of the library of symbols, started on demand.
openOn(NativeSymbols symbols, String path, String options) → Future<Result<(NativeWorker, int), DbError>>
Opens <path>.lmdb with options (JSON) on a running worker of symbols: answers the worker and the handle, or the error the engine answered (such as DbErrorCode.legacyFormat).