IOPort outputPort = (IOPort) outputPorts.next();
Receiver[][] farReceivers = outputPort.getRemoteReceivers();
for (int i = 0; i < farReceivers.length; i++) {
for (int j = 0; j < farReceivers[i].length; j++) {
QueueReceiver farReceiver = (QueueReceiver) farReceivers[i][j];
IOPort port = farReceiver.getContainer();
// Having a self-loop doesn't make it deferrable.
if (port.getContainer() == outputPort.getContainer()) {
continue;
}
int tokenConsumptionRate = _getTokenConsumptionRate(farReceiver);
if ((tokenConsumptionRate >= 0)
&& (farReceiver.size() >= tokenConsumptionRate)) {
deferrable = true;
// Here we find the maximum of the token numbers for
// the actor's output channels which satisfy the demand
// of destination actors while checking deferrability.
// The advantage of this is that it only adds a small
// additional operation for now. If later on we need
// this information, we don't need to do traversing
// again. The disadvantage is that 1) we can return
// from this method as soon as deferrable == true if we
// don't perform this additional operation. 2) We will
// not need this information if it turns out not all
// enabled actors are deferrable. Therefore another
// approach is to perform this operation only when
// needed, i.e., when all enabled actor are deferrable.
if (farReceiver.size() > maxSize) {
maxSize = farReceiver.size();
}
}
}
}
}