CodeSampleX

Beispiel

pool 1.5.2: Run at most N async operations at once in Dart with package:pool, keep the results lined up with the inputs, and know what the timeout actually guards

Verifiziertes Beispiel für pub pool 1.5.2: Run at most N async operations at once in Dart with package:pool, keep the results lined up with the inputs, and…

sha256:16a15d010dc0f1c9e1ee0824cafd5bd1ed1eb32530f108bc856e8cc348fa9179

Dieses Netzwerk bietet eine Sache: ein Sample, das baut. Es hat es in einer Sandbox ausgeführt und die signierte Quittung behalten. Es bewertet nichts und garantiert nichts — ob derselbe Code bei Ihnen baut, hat es nicht gemessen. Wie viele verschiedene Signaturschlüssel eine bestandene Vertragsquittung eingereicht haben. Einer ist der Autor allein; mehr als einer heißt, jemand anderes hat es auch gebaut. Ein Schlüssel wird selbst erzeugt und hat keine registrierte Identität dahinter — gezählt werden Schlüssel, nicht Personen. MIT-0

Ausführungsbelege

Die deklarierte Umgebung und die signierten Läufe stehen getrennt, damit Sie genau sehen, was dieses Sample ausgeführt hat und wo.

Beleggrundlage
Signierter Vertrag bestanden
Verifizierungsbelege
1
Signaturschlüssel, die es gebaut haben
1
Deklarierte Umgebung dart 3 linux x64 dart 3 dart pub

Umgebungen der Verifizierungsläufe

Umgebung Contract Stufen Lauf
dart 3 · linux alpine/x64 · docker ed25519:a2ec939a4c60e243 PASS compile:SKIPPED · contract:PASS · load:PASS · resolve:PASS
CONTAINER_RUN · pub@1
2026-08-14

Fall

HOW
Ziel
Run at most N async operations at once in Dart with package:pool, keep the results lined up with the inputs, and know what the timeout actually guards
Pakete
Symbole
  • Pool
  • Pool.withResource
  • Pool.request
  • Pool.forEach
  • Pool.close
  • Pool.done
  • Pool.isClosed
  • PoolResource
  • PoolResource.release
  • PoolResource.allowRelease
  • TimeoutException
Umgebung
dart 3
Erstellt
2026-08-14T20:09:50Z

Contract

  1. assert a Pool of two runs at most two bodies at once, and that a withResource body that throws still releases its slot, so the high-water mark afterwards is two and not one
  2. assert pool.forEach emits results in completion order rather than input order, so its list is a permutation of the inputs, while Future.wait over withResource keeps every result in position
  3. assert forEach holds every resource in the pool for the whole run, so an unrelated request on the same pool is blocked outright rather than throttled alongside it
  4. assert the default onError adds the error to the stream and carries on, and that returning false only drops the error, with all six elements processed either way
  5. assert toList on a forEach stream completes with the first error, discards the values already emitted and cancels the iteration, so the remaining elements are never attempted
  6. assert an error thrown while iterating the elements bypasses onError entirely and lands on the stream even when onError returns false
  7. assert the timeout is a pool-wide inactivity alarm that any request or release resets, so a starved caller waits nearly three times it, that it then fails every pending request at once with a TimeoutException carrying the configured duration, and that it never fires again for the life of the pool
  8. assert request() throws StateError synchronously on a closed pool while withResource puts the identical error into its returned future instead, and that close() is memoized to one future
  9. assert done completes only once the resources handed out before close are released
  10. assert allowRelease spends the resource token so a following release() throws StateError, that its callback runs only when the slot is wanted, and that a callback which throws completes the next caller's request() with that error and leaves the pool one usable resource short forever
  11. assert queued requests are answered in request order even when it is a later allowRelease callback that frees the slot
  12. assert Pool(0) and a negative limit throw ArgumentError from the constructor, and that queued waiters are served first in, first out

Dateien

  • csx.json
  • lib/throttle.dart
  • pubspec.lock
  • pubspec.yaml
  • test/contract_test.dart

Quellartefakt herunterladen (tar.gz)

Ursprungs-Seeder

anonymous