org.codehaus.gpars

groovyx.gpars.dataflow.impl
[Java] Class SelectBase

java.lang.Object
  groovyx.gpars.dataflow.impl.SelectBase

@java.lang.SuppressWarningsprivate final Collection> pendingRequests = new ArrayList>();
public final class SelectBase

The implementation of the core for all selects.

Authors:
Vaclav Pech Date: 29th Sep 2010


Field Summary
private java.util.List channels

private boolean[] disabledDFVs

Stores the input channel and registers for the wheneverBound() event on each

private int numberOfChannels

private java.util.Collection pendingRequests

private java.util.Random position

 
Constructor Summary
SelectBase(PGroup pGroup, java.util.List channels)

 
Method Summary
void boundNotification(int index, SelectableChannel channel)

Invoked by the SelectCallback instances, potentially concurrently to inform about new values being available for read from channels.

private void disableDFV(int currentPosition, SelectableChannel channel)

Sets the flag in the disabledDFVs array, if the channel is a DFV

void doSelect(int startIndex, SelectRequest selectRequest)

Invoked whenever the Select is asked for the next value.

 
Methods inherited from class java.lang.Object
java.lang.Object#wait(long, int), java.lang.Object#wait(long), java.lang.Object#wait(), java.lang.Object#equals(java.lang.Object), java.lang.Object#toString(), java.lang.Object#hashCode(), java.lang.Object#getClass(), java.lang.Object#notify(), java.lang.Object#notifyAll()
 

Field Detail

channels

private final java.util.List channels


disabledDFVs

private final boolean[] disabledDFVs
Stores the input channel and registers for the wheneverBound() event on each
Parameters:
pGroup - The group, the thread pool of which should be used for notification message handlers
channels - All the input channels to select on


numberOfChannels

private final int numberOfChannels


pendingRequests

private final java.util.Collection pendingRequests


position

@java.lang.SuppressWarningsfinal SelectableChannel channel = channels.get(i);
private final java.util.Random position


 
Constructor Detail

SelectBase

public SelectBase(PGroup pGroup, java.util.List channels)


 
Method Detail

boundNotification

@java.lang.SuppressWarnings
void boundNotification(int index, SelectableChannel channel)
Invoked by the SelectCallback instances, potentially concurrently to inform about new values being available for read from channels.
throws:
InterruptedException If the thread is interrupted during value retrieval from the channel
Parameters:
index - The index of the ready channel
channel - The channel itself


disableDFV

private void disableDFV(int currentPosition, SelectableChannel channel)
Sets the flag in the disabledDFVs array, if the channel is a DFV
Parameters:
currentPosition - The position to mark
channel - The channel being considered


doSelect

public void doSelect(int startIndex, SelectRequest selectRequest)
Invoked whenever the Select is asked for the next value. Depending on the supplied startIndex value it scans all input channels and reads the first one found, which currently has a value available for read. If no input channel is ready, the supplied SelectRequest instance is registered to be notified by the wheneverBound() channel listeners.
throws:
InterruptedException If the thread gets interrupted while reading messages from the channels
Parameters:
startIndex - The index of the channel to check first for available messages, -1 if start at a random position. Continue scanning by increasing the index, once the size is reached start from 0.
selectRequest - The request that holds the guards and expects a notification once a value is selected


 

Copyright © 2008–2013 Václav Pech. All Rights Reserved.