cbus: add pair/unpair helpers
This patch introduces cbus_pair() and cbus_unpair() helpers to pair/unpair two existing cbus endpoints in one function call. cbus_pair() creates pipes from the caller's cord to the given destination and back. It blocks the caller until both pipes are created. The caller may specify a callback to be called at the destination right after the pipe to the source has been created, which may be useful for preparing the destination to receiving messages from the source. cbus_unpair() initiates destruction of pipes created with cbus_pair() and blocks the caller until destruction is complete. Since there may be messages queued at the destination endpoint when this function is called, before proceeding to pipe destruction this function flushes all messages at the destination by sending an empty message from the source to the destination and back. The caller may specify a callback to be invoked by this message at the destination endpoint. This can be used to notify the destination that the channel is about to be destroyed and it must stop generating new messages.
Loading
Please register or sign in to comment