parallel_dart 0.0.1+1 icon indicating copy to clipboard operation
parallel_dart: ^0.0.1+1 copied to clipboard

Execute code in multicore easily.

Running isolate easily.

Features #

Give more power to your app with multicore processing.

Getting started #

    import 'dart:io';

    void main() {
        // run core dedicated isolates.
            numberOfIsolates: Platform.numberOfProcessors -1, // minus one used for allocating to main isolate.
            maxConcurrentPerIsolate: 100, // limit to 100 execution per isolate
            onInitialization: () {
                // register your dependency injection
                // for example using GetIt.I.register...


Usage #

Execute action in isolate.

final result = await{
    // do your heavy task here.

Execute action in main isolate from worker isolate.

final result = await{
    final data = await Parallel.runInMain((){
        // get your main data


Additional information #

WARNING: Since isolates are not sharing memory each other, you have to make sure the data that passed between isolates are not mutable.