Search packages, repositories and app categories

GitHub repositorygaaclarke/agents

agents

Dart package that conveniently wraps an isolate, ports and state for easy isolates.

agents project cover
Stars
85
Forks
6
Last push (UTC)
Jun 23, 2024
Project status
Active

Original README

English project snapshot. Visit GitHub for the latest content.

Isolate Agents

Description

Isolate Agents adds a new class, Agent, which is a proper implementation of the Actor model for Dart. Where Isolates have no mechanism for communication, Agents do. It is inspired by Clojure's agents.

Example usage

import 'package:isolate_agents/isolate_agents.dart';

void main() async {
  Agent<int> agent = await Agent.create(() => 1);
  // The following add operation is executed in the Agent's isolate.
  agent.update((int x) => x + 1);
  assert(2 == await agent.exit());
}

Why?

After writing Dart code for a couple of years I realized I was writing the same code over and over again in order to be able to use Isolates. Isolates don't fully implement the Actor model so a handshake of SendPort and a protocol needs to be devised for each non-trivial usage of Isolates. Agents factor all that logic into a reusable package, eliminating the SendPort handshake and standardizing the protocol.

gaaclarke GitHub avatar
GitHub author

gaaclarke ↗

Seattle, WA
LanguagesDart

Packages published by this repository

Dependencies used

Dependency list 2 items

How do I choose a repository?

Start with your use case, compare repository activity, and check the original project before adopting it.

  1. Search by repository name, owner or description, then narrow the results by topic.
  2. Compare stars, forks and recent pushes. Stars show community interest, not a guarantee of quality.
  3. Read the README, license and issues on GitHub before using a project.

Sources and maintenance

“A repository is the most basic element of GitHub.”

GitHub Docs — About repositories ↗