BoundedSender

struct BoundedSender<T>

A clonable producer endpoint with atomic capacity reservation.

Unlike Sender, send waits while the queue is full. Reservations prevent multiple workers from overfilling the bound, and receiver closure wakes blocked producers so they can return false.

Methods

func send(consume value: T) -> Bool

Waits for a queue slot and transfers value, returning true on delivery.

Returns false if the receiver is gone before a slot is reserved; the undelivered value is then dropped by the caller-side typed path.

View Source
pub func send(consume value: T) -> Bool {
	loop {
		if _chan_ctl(handle: self.handle, op: 9) == 0 {
			return false
		}
		if _chan_ctl(handle: self.handle, op: 10) == 1 {
			_chan_send(handle: self.handle, value: value)
			return true
		}
		'wait(reasons: [WaitReason.send(self.handle)])
	}
}