Skip to content

Introduction

d-markey edited this page Jun 22, 2023 · 9 revisions

Squadron

Multithreading and worker pools in Dart.

Offload CPU-bound and long running tasks and give your mobile and Web apps some air!

Pub Package Dart Platforms Flutter Platforms

License Null Safety Dart Style Pub Points Likes Popularity

Last Commit Dart Workflow Code Lines Code Coverage

Introduction

Dart is a programming language developed by Google, designed for building high-performance, cross-platform applications. Applications built with Dart can run in various environments, including Web browsers, mobile devices, desktops, and servers.

When running a Dart application, especially in asynchronous scenarios, an event loop plays a crucial role in managing and coordinating the execution of tasks within the program. The event loop is a fundamental concept in event-driven programming, allowing an application to handle multiple concurrent tasks without blocking or waiting for each task to complete before moving on to the next one. Instead, the event loop continuously monitors and dispatches events and tasks, ensuring efficient and non-blocking execution.

In the context of Dart, the event loop is provided by the underlying Dart runtime which is responsible for executing Dart code. Typically, when a Dart program is started, the Dart runtime executes the program's entry point (the main() function), and then handles all pending events queued to the event-loop before exiting. It is important to note that when a block of code starts executing, it will not be interrupted; instead, it may trigger events or tasks that will be picked up by the event-loop at a later point in time.

Dart's main Isolate Dart's main Isolate

Dart also implements the concept of isolates: execution units that have their own private memory space. On native platforms, isolates are implemented in Dart's Isolate class; on Web platforms, isolates map to Web Workers. While Isolates and Web Workers are conceptually the same, they are not interchangeable at code level and require specific attention.

This dichotomy makes it hard to write code that will run happily on both native and Web platforms.

Squadron is here to bridge that gap.

Clone this wiki locally