mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-11-16 17:09:31 +01:00
14 lines
299 B
Dart
14 lines
299 B
Dart
import 'dart:async';
|
|
|
|
import 'package:isolate/isolate.dart';
|
|
|
|
Future<T> runInBackground<T, U>(
|
|
FutureOr<T> Function(U arg) function, U arg) async {
|
|
final isolate = await IsolateRunner.spawn();
|
|
try {
|
|
return await isolate.run(function, arg);
|
|
} finally {
|
|
await isolate.close();
|
|
}
|
|
}
|