global

def dispatch(events, &reactivate)

Dispatch the given events to the list of waiting fibers. If the fiber was not waiting for the given events, it is reactivated by calling the given block.
def dispatch(events, &reactivate)
	# We capture the tail here, because calling reactivate might modify it:
	tail = self.tail
	
	if fiber = self.fiber
		if fiber.alive?
			revents = events & self.events
			if revents.zero?
				reactivate.call(self)
			else
				self.fiber = nil
				fiber.transfer(revents)
			end
		else
			self.fiber = nil
		end
	end
	
	tail&.dispatch(events, &reactivate)
end