Skip to content

Introduction

d-markey edited this page Sep 22, 2024 · 9 revisions

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, from Web browsers to mobile devices to servers, from Windows to Linux and Android to iOS.

Dart application are asynchronous in essence: the Dart runtime is built upon an event loop that runs pieces of code one after another. The event loop is a fundamental concept in event-driven programming, managing and coordinating the execution of tasks within the program 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 of code.

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 more events and tasks that will be picked up by the event-loop at a later point in time.

As a result, tasks and events posted to an event-loop will execute one at a time.

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. Each isolate manages its own event-loop. 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 multithreaded code that will run happily on both native and Web platforms.

Squadron is here to bridge that gap.

Squadron supports all platforms: native and Web including Web Assembly.

Dart's main Isolate Dart's main Isolate


Squadron logo

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

Clone this wiki locally