-
Notifications
You must be signed in to change notification settings - Fork 16
Open
Description
At least trySend() 🙏
TL;DR
Add non-blocking trySend(T) and tryReceive() methods to Channel to enable integration with NIO frameworks (Netty, Vert.x, etc.), where blocking the event loop thread is prohibited.
- Should return immediately without parking the virtual thread
- Must be safe to call from platform threads (event loops)
- Should respect channel capacity: return false/full for full buffered channels
- Consider atomic operations for rendezvous channels (immediate failure if no waiting receiver)
e.g:
vertx.eventBus().consumer("events", msg -> {
// Non-blocking channel operation in event loop
if (channel.trySend(msg.body())) {
msg.reply("Accepted");
} else {
msg.reply("Channel full, backpressure applied");
}
});
Kotlin provides https://kotlinlang.org/api/kotlinx.coroutines/kotlinx-coroutines-core/kotlinx.coroutines.channels/-send-channel/try-send.html and tryReceive() returning ChannelResult
Project Reactor has tryEmitNext() for similar NIO integration
Metadata
Metadata
Assignees
Labels
No labels