Skip to content

Commit

Permalink
up
Browse files Browse the repository at this point in the history
  • Loading branch information
committed Jan 16, 2025
1 parent 078a6a9 commit b6b0877
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 11 deletions.
8 changes: 4 additions & 4 deletions package/server_universe/lib/fork/mime_type/mime_type.dart
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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()) {
Expand Down
2 changes: 1 addition & 1 deletion package/server_universe/lib/fork/queue/queue.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
library dart_queue;
library;

export 'src/dart_queue_base.dart' hide unawaited;
17 changes: 11 additions & 6 deletions package/server_universe/lib/fork/queue/src/dart_queue_base.dart
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// ignore_for_file: deprecated_member_use_from_same_package

import 'dart:async';

class _QueuedFuture<T> {
Expand Down Expand Up @@ -61,10 +63,11 @@ class Queue {
int parallel;
int _lastProcessId = 0;
bool _isCancelled = false;


///
bool get isCancelled => _isCancelled;
StreamController<int>? _remainingItemsController;

///
Stream<int> 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?
Expand All @@ -86,11 +89,12 @@ class Queue {

@Deprecated(
"v4 - listen to the [remainingItems] stream to listen to queue status")
///
Set<int> 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]
///
Expand All @@ -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.
Expand Down Expand Up @@ -141,7 +145,7 @@ class Queue {
/// When each item completes it will only fire up one othe process
///
Future<void> _process() async {
if (activeItems.length < parallel) {
if (activeItems.length < parallel) {
_queueUpNext();
}
}
Expand Down Expand Up @@ -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<void> future) {}

0 comments on commit b6b0877

Please sign in to comment.