Skip to main content

Practice · 2 of 4

The Bounded Channel

CHALLENGE
Difficulty: intermediate+25 XP

Implement a FIFO channel with a capacity: TryProduce returns false when full, TryConsume returns null when empty, Count reports items waiting. ``csharp public sealed class BoundedChannel { public BoundedChannel(int capacity); public bool TryProduce(string item); // false when at capacity public string? TryConsume(); // oldest item, or null when empty public int Count { get; } } ``

Back to lesson: Practice: Concurrency Practice: Counters, Limits, Deadlocks