diff --git a/lib/mailbox.dart b/lib/mailbox.dart index b9a4917..51393c7 100644 --- a/lib/mailbox.dart +++ b/lib/mailbox.dart @@ -113,8 +113,8 @@ class Mailbox { /// Gets the [Mailbox]'s state which can change concurrently. /// Once a [Mailbox] has reached the [MailboxState.closed] /// state it can no longer change state. - MailboxState get state => _mutex.runLocked(() - => MailboxState.from(_mailbox.ref.state)); + MailboxState get state => + _mutex.runLocked(() => MailboxState.from(_mailbox.ref.state)); bool isEmpty() => state == MailboxState.empty; @@ -215,7 +215,7 @@ class Mailbox { return _emptyResponse; } - // TODO: remove feature detection once 3.1 becomes stable. + // TODO(Slava.Egorva): remove feature detection once 3.1 becomes stable. // ignore: omit_local_variable_types final Uint8List Function(int) asTypedList = buffer.asTypedList; if (asTypedList is Uint8List Function(int, diff --git a/lib/sendable.dart b/lib/sendable.dart index df8d42b..86d4a81 100644 --- a/lib/sendable.dart +++ b/lib/sendable.dart @@ -3,8 +3,8 @@ // BSD-style license that can be found in the LICENSE file. abstract final class Sendable { - static Sendable wrap(T Function(U) make, U data) - => _SendableImpl._(make, data); + static Sendable wrap(T Function(U) make, U data) => + _SendableImpl._(make, data); T materialize(); } diff --git a/test/mailbox_test.dart b/test/mailbox_test.dart index 2105c90..2e1a5ae 100644 --- a/test/mailbox_test.dart +++ b/test/mailbox_test.dart @@ -41,19 +41,20 @@ void main() { expect(await helperResult, equals('success')); }); - Future startHelperIsolateClose(Sendable sendableMailbox) - // ignore: discarded_futures - => Isolate.run(() { - sleep(const Duration(milliseconds: 500)); - final mailbox = sendableMailbox.materialize(); - try { - mailbox.take(); - // ignore: avoid_catches_without_on_clauses - } catch (_) { - return 'success'; - } - return 'failed'; - }); + Future startHelperIsolateClose(Sendable sendableMailbox) + // ignore: discarded_futures + => + Isolate.run(() { + sleep(const Duration(milliseconds: 500)); + final mailbox = sendableMailbox.materialize(); + try { + mailbox.take(); + // ignore: avoid_catches_without_on_clauses + } catch (_) { + return 'success'; + } + return 'failed'; + }); test('mailbox close', () async { final mailbox = Mailbox() diff --git a/test/primitives_test.dart b/test/primitives_test.dart index 968ea0c..e5e7295 100644 --- a/test/primitives_test.dart +++ b/test/primitives_test.dart @@ -29,8 +29,9 @@ void main() { /// Returns success /// Future spawnHelperIsolate( - // ignore: discarded_futures - int ptrAddress, Sendable sendableMutex) => Isolate.run(() { + int ptrAddress, Sendable sendableMutex) { + // ignore: discarded_futures + return Isolate.run(() { final ptr = Pointer.fromAddress(ptrAddress); final mutex = sendableMutex.materialize(); @@ -51,6 +52,7 @@ void main() { return 'success'; }); + } test('isolate', () async { await using((arena) async { @@ -105,21 +107,22 @@ void main() { group('condvar', () { Future spawnHelperIsolate( - int ptrAddress, - Sendable sendableMutex, - Sendable sendableCondVar) async => Isolate.run(() { - final ptr = Pointer.fromAddress(ptrAddress); - final mutex = sendableMutex.materialize(); - final condVar = sendableCondVar.materialize(); - - return mutex.runLocked(() { - ptr.value = 1; - while (ptr.value == 1) { - condVar.wait(mutex); - } - return ptr.value == 2 ? 'success' : 'failure'; + int ptrAddress, + Sendable sendableMutex, + Sendable sendableCondVar) async => + Isolate.run(() { + final ptr = Pointer.fromAddress(ptrAddress); + final mutex = sendableMutex.materialize(); + final condVar = sendableCondVar.materialize(); + + return mutex.runLocked(() { + ptr.value = 1; + while (ptr.value == 1) { + condVar.wait(mutex); + } + return ptr.value == 2 ? 'success' : 'failure'; + }); }); - }); test('isolate', () async { await using((arena) async {