#include <channel_decls.h>
Public Member Functions | |
ChannelGroup (ChannelManager &m) | |
ChannelGroup constructor. | |
void | addChannel (BaseChannel &chan) |
Adds given channel to this group. | |
void | removeChannel (BaseChannel &chan) |
Removes given channel from this group. | |
BaseChannel * | tryselect () const |
Tries to find a channel where messages are available. | |
BaseChannel & | select () const |
Blockingly finds a channel where messages are available. |
Channels can be added and removed to and from a group using addChannel() and removeChannel(). The methods select() and tryselect() can be used to find a channel with pending messages. A group may only be used by exactly one microthread.
ChannelGroup::ChannelGroup | ( | ChannelManager & | m | ) | [inline] |
void ChannelGroup::addChannel | ( | BaseChannel & | chan | ) |
Adds given channel to this group.
A tryselect() or select() will then take this channel into account.
chan | is the channel to add |
void ChannelGroup::removeChannel | ( | BaseChannel & | chan | ) |
Removes given channel from this group.
A tryselect() or select() will no longer respond to messages on this channel.
chan | is the channel to remove |
BaseChannel * ChannelGroup::tryselect | ( | ) | const |
Tries to find a channel where messages are available.
It is guarantueed that two messages arriving on one channel are selected chronologically. It is furthermore guaranteed that two messages sent on two channels within this group are selected chronologically. This only takes message arrival into account. If two microthreads try to concurrently send messages to channels the one wining the lock of the manager will be first.
BaseChannel & ChannelGroup::select | ( | ) | const |
Blockingly finds a channel where messages are available.
Please read the docs about tryselect(). If there are no messages available the current microthread is suspended until messages are available.