From b6b08771b71de3da51782219a6bf5a014e30ad3c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E2=80=8E?= <‎> Date: Fri, 17 Jan 2025 00:11:03 +0700 Subject: [PATCH] up --- .../lib/fork/mime_type/mime_type.dart | 8 ++++---- .../server_universe/lib/fork/queue/queue.dart | 2 +- .../lib/fork/queue/src/dart_queue_base.dart | 17 +++++++++++------ 3 files changed, 16 insertions(+), 11 deletions(-) diff --git a/package/server_universe/lib/fork/mime_type/mime_type.dart b/package/server_universe/lib/fork/mime_type/mime_type.dart index 6f36c85..1b4f271 100644 --- a/package/server_universe/lib/fork/mime_type/mime_type.dart +++ b/package/server_universe/lib/fork/mime_type/mime_type.dart @@ -1,8 +1,8 @@ -library mime_type; +library; import 'dart:collection'; -// get MIME type from file name (returns null if there is no such extension) +/// get MIME type from file name (returns null if there is no such extension) String? mime(String? fileName) { if (fileName == null || fileName.trim().isEmpty) { return null; @@ -17,10 +17,10 @@ String? mime(String? fileName) { } } -// get MIME type from extension (returns null if there is no such extension) +/// get MIME type from extension (returns null if there is no such extension) String? mimeFromExtension(String extension) => _mimeMaps[extension]; -// gets extension from MIME type (returns null if there is no such mime type) +/// gets extension from MIME type (returns null if there is no such mime type) String? extensionFromMime(String mime) { for (final key in _mimeMaps.keys) { if (_mimeMaps[key] == mime.toLowerCase()) { diff --git a/package/server_universe/lib/fork/queue/queue.dart b/package/server_universe/lib/fork/queue/queue.dart index 20c3d8d..c893abb 100644 --- a/package/server_universe/lib/fork/queue/queue.dart +++ b/package/server_universe/lib/fork/queue/queue.dart @@ -1,3 +1,3 @@ -library dart_queue; +library; export 'src/dart_queue_base.dart' hide unawaited; diff --git a/package/server_universe/lib/fork/queue/src/dart_queue_base.dart b/package/server_universe/lib/fork/queue/src/dart_queue_base.dart index eadd3bc..6cecff6 100644 --- a/package/server_universe/lib/fork/queue/src/dart_queue_base.dart +++ b/package/server_universe/lib/fork/queue/src/dart_queue_base.dart @@ -1,3 +1,5 @@ +// ignore_for_file: deprecated_member_use_from_same_package + import 'dart:async'; class _QueuedFuture { @@ -61,10 +63,11 @@ class Queue { int parallel; int _lastProcessId = 0; bool _isCancelled = false; - + + /// bool get isCancelled => _isCancelled; StreamController? _remainingItemsController; - + /// Stream get remainingItems { // Lazily create the remaining items controller so if people aren't listening to the stream, it won't create any potential memory leaks. // Probably not necessary, but hey, why not? @@ -86,11 +89,12 @@ class Queue { @Deprecated( "v4 - listen to the [remainingItems] stream to listen to queue status") + /// Set activeItems = {}; /// Returns the number of items that are currently processed /// And the number of items in queue - int get remainingItemCount => _nextCycle.length + activeItems.length; + int get remainingItemCount => _nextCycle.length + activeItems.length; /// Cancels the queue. Also cancels any unprocessed items throwing a [QueueCancelledException] /// @@ -112,7 +116,7 @@ class Queue { _remainingItemsController?.close(); cancel(); } - + /// Queue({this.delay, this.parallel = 1, this.timeout, this.lifo = false}); /// Adds the future-returning closure to the queue. @@ -141,7 +145,7 @@ class Queue { /// When each item completes it will only fire up one othe process /// Future _process() async { - if (activeItems.length < parallel) { + if (activeItems.length < parallel) { _queueUpNext(); } } @@ -184,7 +188,8 @@ class Queue { } } +/// class QueueCancelledException implements Exception {} -// Don't throw analysis error on unawaited future. +/// Don't throw analysis error on unawaited future. void unawaited(Future future) {}