mirror of
https://gitlab.com/famedly/fluffychat.git
synced 2024-12-11 06:19:28 +01:00
13 lines
298 B
Dart
13 lines
298 B
Dart
|
import 'package:isolate/isolate.dart';
|
||
|
import 'dart:async';
|
||
|
|
||
|
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();
|
||
|
}
|
||
|
}
|