remove unused code

This commit is contained in:
Hiroshi Horie
2022-03-06 14:10:18 +09:00
parent ead3a7ea6a
commit 47b9329c67
3 changed files with 1 additions and 53 deletions
-7
View File
@@ -13,7 +13,6 @@ import '../extensions.dart';
import '../internal/events.dart';
import '../internal/types.dart';
import '../logger.dart';
import '../managers/delay.dart';
import '../managers/event.dart';
import '../options.dart';
import '../proto/livekit_models.pb.dart' as lk_models;
@@ -71,8 +70,6 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
late final _signalListener = signalClient.createListener(synchronized: true);
final delays = CancelableDelayManager();
Engine({
SignalClient? signalClient,
PeerConnectionCreate? peerConnectionCreate,
@@ -90,7 +87,6 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
onDispose(() async {
await cleanUp();
await events.dispose();
await delays.dispose();
await _signalListener.dispose();
});
}
@@ -141,9 +137,6 @@ class Engine extends Disposable with EventsEmittable<EngineEvent> {
Future<void> cleanUp() async {
logger.fine('[${objectId}] cleanUp()');
// cancel all ongoing delays
await delays.cancelAll();
await publisher?.dispose();
publisher = null;
+1 -1
View File
@@ -517,4 +517,4 @@ extension RoomDebugMethods on Room {
serverLeave: serverLeave,
);
}
}
}
-45
View File
@@ -1,45 +0,0 @@
import 'package:async/async.dart';
import '../support/disposable.dart';
class CancelableDelayManager extends Disposable {
//
final _delays = <CancelableOperation<void>>[];
CancelableDelayManager() {
onDispose(() async => await cancelAll());
}
// delay but cancelable
Future<void> waitFor(
Duration wait, {
Function? ifNotCancelled,
}) async {
final op = CancelableOperation<void>.fromFuture(
Future<void>.delayed(wait),
);
_delays.add(op);
await op.valueOrCancellation();
_delays.remove(op);
// if it was cancelled we probably don't want to execute it
if (!op.isCanceled) ifNotCancelled?.call();
}
// @override
// Future<bool> dispose() async {
// final didDispose = await super.dispose();
// if (didDispose) {
// await cancelAll();
// }
// return didDispose;
// }
Future<void> cancelAll() async {
// cancel all delays
if (_delays.isEmpty) return;
// make a copy so we don't mutate while iterating
final snapshot = List<CancelableOperation<void>>.from(_delays);
for (final op in snapshot) {
await op.cancel();
}
}
}