generic_pool

Usage

import 'package:generic_pool/generic_pool.dart' as pool;

main() async {
  var dial = () async {
    print('+1');
    return 'a';
  };

  var close = (dynamic c) async {
    print('-1');
  };

  var cc = pool.pool(dial, close, 1, maxActive: 2);
  try {
    await cc.get();
    await cc.get();
    var x = await cc.get();
    await cc.get();
    print(x);
    await cc.put(x, false);
    print(cc.activeCount);
    var xx = await cc.get();
    await cc.put(xx, true);
    print(cc.activeCount);
  } on Exception catch (e) {
    print(e == pool.ErrPoolExhausted);
  }
}

Libraries

generic_pool