HomeChallengesRepsProblemsLeaderboardTake a challenge

The permit you never gave back

A throttle that stops throttling, then stops working entirely.

Intermediate18 min on the clock5 graded checks · 100 pointsResources and ConcurrencyPro
Graded by reading your code against the checklist below.

What you build

  • Share one semaphore rather than creating one per call
  • Wait asynchronously instead of blocking
  • Release in a finally, so an exception cannot strand the permit
  • Pass the cancellation token to the wait
  • Dispose the semaphore

Done means

One shared semaphore, awaited with the token, released in a finally, and disposed.

How it is graded

Published in full, before you start — every point is one of these and there is nothing else.

  1. Release runs in a finally+35Limiting how much runs at once
  2. The wait is asynchronous+20Limiting how much runs at once
  3. One semaphore, shared+20Limiting how much runs at once
  4. The wait honours cancellation+15Limiting how much runs at once
  5. The semaphore is disposed+10Giving resources back

What it teaches

The rest of Resources and Concurrency