StandaloneService class

A Service that starts itself immediately upon construction.

Use this when a service should run independently without being added to a ServicePool. The service's start_service C function is called in the constructor. Call dispose (inherited from Service) to invoke stop_service and release the native callback when done.

Example

class LoggerService extends StandaloneService {
  LoggerService(super.libname) {
    log = lib
        .lookup<NativeFunction<Void Function()>>('log_message')
        .asFunction<void Function()>();
  }

  late final void Function() log;
}

final logger = LoggerService('liblogger.so');
logger.log(); // C++ service already running
// ...
logger.dispose();
Inheritance

Constructors

StandaloneService(String libname)
Opens libname, registers the notification callback, and immediately calls start_service.

Properties

freeMessage ↔ void Function(Pointer<BackendMsg>)
Bound to the C free_message() function.
getter/setter pairinherited
getNextMessage Pointer<BackendMsg> Function()
Bound to the C get_next_message() function.
getter/setter pairinherited
hashCode int
The hash code for this object.
no setterinherited
lib DynamicLibrary
The opened DynamicLibrary. Available to subclasses for binding additional native functions.
getter/setter pairinherited
libname String
Path to the shared library, as passed to DynamicLibrary.open.
finalinherited
messageController StreamController<Pointer<BackendMsg>>
Broadcast stream of raw message pointers drained from the C++ queue.
finalinherited
messageStream Stream<Pointer<BackendMsg>>
The broadcast stream fed by messageController.
no setterinherited
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
startService ↔ void Function()
Bound to the C start_service() function.
getter/setter pairinherited
stopService ↔ void Function()
Bound to the C stop_service() function.
getter/setter pairinherited

Methods

assignJob(void job(Pointer<BackendMsg>)) → void
Registers job as the handler invoked for every message emitted by this service.
inherited
dispose() → void
Stops the service and releases the native callback.
inherited
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