worker_manager 1.1.2 copy "worker_manager: ^1.1.2" to clipboard
worker_manager: ^1.1.2 copied to clipboard

outdated

Executor allows you to create a queue of tasks for threadpool of isolates

example/lib/main.dart

// Copyright Daniil Surnin. All rights reserved.
// Use of this source code is governed by a Apache license that can be
// found in the LICENSE file.

import 'dart:async';

import 'package:flutter/foundation.dart';
import 'package:flutter/material.dart';
import 'package:http/http.dart';
import 'package:worker_manager/worker_manager.dart';

void main() async {
  await Executor().warmUp();
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      showPerformanceOverlay: true,
      home: MyHomePage(),
    );
  }
}

class MyHomePage extends StatefulWidget {
  MyHomePage({Key key}) : super(key: key);

  @override
  _MyHomePageState createState() => _MyHomePageState();
}

class _MyHomePageState extends State<MyHomePage> {
  @override
  Widget build(BuildContext context) {
    return Scaffold(
      body: Center(
        child: RaisedButton(
            child: Text('fib(40)'),
            onPressed: () {
              int i = 0;
              while (i < 1000) {
                Executor(threadPoolSize: 1)
                    .addTask<int, int>(task: Task<int, int>(function: fib, bundle: 40))
                    .listen((data) {
                  print(data);
                });
                i++;
              }
            }),
      ),
    );
  }
}

int fib(int n) {
  if (n < 2) {
    return n;
  }
  return fib(n - 2) + fib(n - 1);
}

Future<String> getData(String link) async => (await get(link)).body.toString();
301
likes
0
pub points
94%
popularity

Publisher

verified publisherrenesanse.net

Executor allows you to create a queue of tasks for threadpool of isolates

Repository (GitHub)
View/report issues

License

unknown (LICENSE)

Dependencies

async, flutter, uuid

More

Packages that depend on worker_manager