Example #1
0
 /**
  * Constructs a new message that requires multiple channels to have read it.
  *
  * @param requiredRead The channels that need to have read the message
  */
 public ChannelMessage(Channel... requiredRead) {
   short required = 0;
   for (Channel channel : requiredRead) {
     required |= channel.getMask();
   }
   requiredMask = required;
 }
Example #2
0
 /**
  * Marks a channel as having read the message.
  *
  * @param channel The channel that has read the message
  */
 public void markChannelRead(Channel channel) {
   boolean done = false;
   while (!done) {
     int readOld = read.get();
     int readNew = readOld | channel.getMask();
     done = read.compareAndSet(readOld, readNew);
   }
 }
Example #3
0
 /**
  * Returns true if the channel has read the message, false if otherwise.
  *
  * @param channel The channel to check
  * @return Whether or not the channel has read the message
  */
 public boolean isChannelRead(Channel channel) {
   return (read.get() & channel.getMask()) == channel.getMask();
 }
Example #4
0
 /**
  * Constructs a new message that requires a single channel to have read it.
  *
  * @param requiredRead The channel that needs to read the message
  */
 public ChannelMessage(Channel requiredRead) {
   requiredMask = requiredRead.getMask();
 }