Hi guys, I'm trying to use `Channel.onUndeliveredE...
# coroutines
v
Hi guys, I'm trying to use
Channel.onUndeliveredElement
callback, and I'm wondering why it is a `null`able lambda instead of a non-null lambda with an empty block
{}
parameter? Is there anything specific in the implementation that makes passing
null
any different from passing
{}
over there?
I have dug through the source code, but it's so complicated inside the
BufferedChannel
I can't understand a thing of what's going on there, but to me it looks that that distinction was only made for performance reasons to skip some invocations of callbacks inside the Channel machinery. Can someone on the team explain what are the performance implications of passing an empty block as
onUndeliveredElement
to the channel instead of null? I'm using it in a relatively high-load scenario where the channel may be under big throughput, but I can't really determine if any of the users of my public api provided any code in the
onUndeliveredElement
handler, so it will be simple for me to always pass a lambda there instead of complicating the API trying to determine if the callback has meaningful logic or not and passing null there in that case. So does it really make sense to try and keep the lambda as null if it has no meaningful logic there at the cost of a more complex api?
I still haven't found an answer ;(