parallel_dart 0.0.1+1 copy "parallel_dart: ^0.0.1+1" to clipboard
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.
        Parallel.initialize(
            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...
            },
        );

        runApp(MyApp());
    }

Usage #

Execute action in isolate.

final result = await Parallel.run((){
    // do your heavy task here.
});

Execute action in main isolate from worker isolate.

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

    print(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.

3
likes
140
points
10
downloads

Publisher

verified publishermaseka.dev

Weekly Downloads

Execute code in multicore easily.

Repository (GitHub)

Documentation

API reference

License

MIT (license)

Dependencies

flutter

More

Packages that depend on parallel_dart