https://kotlinlang.org logo
Title
d

Didier Villevalois

08/17/2021, 12:33 PM
Hi everyone! I'm trying to design a Kotlin API for ZeroMQ. My API currently resembles a lot to the `SendChannel`/`ReceiveChannel` API. I would like to implement some
onReceive: SelectClause1<Message>
and
onSend: SelectClause2<Message, SendSocket>
similar to the ones of the
Channel
API. Searching in this channel, I found: 1. some helpers to build select clauses https://gist.github.com/zach-klippenstein/fa4366388295282fa409c5085abada23 by @Zach Klippenstein (he/him) [MOD], however it seems to me that there are made to work with event callbacks, 2. a suggestion by @Matej Drobnič to use something like
async { mySuspendFunction() }.onAwait
, however I can't seem to build a proper
SelectClause1
with this. As ZeroMQ uses a polling mechanism, I don't quite figure out how to use either of these solutions. Also, the
AbstractChannel
code is quite overwhelming. Is there a paper/article discussing the possible
SelectClause
implementations somewhere? Do anyone of you have some hints or advices to give me? Thanks in advance!
n

Nick Allen

08/17/2021, 6:25 PM
Alternatively, you could consider using a Channel directly in your API or the API's implementation?