blob: e3ae604e0f57f8327b85ae89f729bb4973b99e29 [file] [log] [blame]
// Copyright 2015 The Vanadium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
part of syncbase_client;
// UnclosedStubsManager is used to track Mojo stubs to close when the Syncbase
// client is closed.
class UnclosedStubsManager {
List _stubs = [];
UnclosedStubsManager._internal();
register(stub) {
_stubs.add(stub);
}
close(stub) {
bool exists = _stubs.remove(stub);
if (!exists) {
throw new ArgumentError.value(stub, 'stub',
'Stub has not been registered, or has already been closed.');
}
stub.close();
}
Future closeAll({immediate: false}) {
return Future.wait(_stubs.map((s) => s.close(immediate: immediate)));
}
}