exec<T> method
Implementation
Future<T?> exec<T>(Future<T> future) {
if (!_enable) {
return Future<T>.error('This Executor is disable');
}
UniqueKey key = UniqueKey();
CancelableOperation<T> operation =
CancelableOperation.fromFuture(future, onCancel: () {
if (_enable) {
_futures.remove(key);
}
});
_futures.putIfAbsent(key, () => operation);
operation.value.whenComplete(() {
if (_enable) {
_futures.remove(key);
}
});
return operation.valueOrCancellation();
}