use of org.agrona.concurrent.status.ReadablePosition in project aeron by real-logic.
the class IpcPublication method updatePublisherLimit.
int updatePublisherLimit() {
int workCount = 0;
long minSubscriberPosition = Long.MAX_VALUE;
long maxSubscriberPosition = consumerPosition;
for (final ReadablePosition subscriberPosition : subscriberPositions) {
final long position = subscriberPosition.getVolatile();
minSubscriberPosition = Math.min(minSubscriberPosition, position);
maxSubscriberPosition = Math.max(maxSubscriberPosition, position);
}
if (subscriberPositions.length > 0) {
if (maxSubscriberPosition > consumerPosition) {
consumerPosition = maxSubscriberPosition;
}
final long proposedLimit = minSubscriberPosition + termWindowLength;
if (proposedLimit > tripLimit) {
publisherLimit.setOrdered(proposedLimit);
tripLimit = proposedLimit + tripGain;
cleanBuffer(minSubscriberPosition);
workCount = 1;
}
} else if (publisherLimit.get() > consumerPosition) {
tripLimit = consumerPosition;
publisherLimit.setOrdered(consumerPosition);
}
return workCount;
}
use of org.agrona.concurrent.status.ReadablePosition in project Aeron by real-logic.
the class NetworkPublication method updatePublisherLimit.
/**
* Update the publishers limit for flow control as part of the conductor duty cycle.
*
* @return 1 if the limit has been updated otherwise 0.
*/
int updatePublisherLimit() {
int workCount = 0;
if (State.ACTIVE == state) {
final long senderPosition = this.senderPosition.getVolatile();
if (hasRequiredReceivers() || (spiesSimulateConnection && spyPositions.length > 0)) {
long minConsumerPosition = senderPosition;
for (final ReadablePosition spyPosition : spyPositions) {
minConsumerPosition = Math.min(minConsumerPosition, spyPosition.getVolatile());
}
final long proposedPublisherLimit = minConsumerPosition + termWindowLength;
final long publisherLimit = this.publisherLimit.get();
if (proposedPublisherLimit > publisherLimit) {
cleanBufferTo(minConsumerPosition - termBufferLength);
this.publisherLimit.setOrdered(proposedPublisherLimit);
workCount = 1;
}
} else if (publisherLimit.get() > senderPosition) {
publisherLimit.setOrdered(senderPosition);
cleanBufferTo(senderPosition - termBufferLength);
workCount = 1;
}
}
return workCount;
}
use of org.agrona.concurrent.status.ReadablePosition in project Aeron by real-logic.
the class PublicationImage method positionArray.
private ReadablePosition[] positionArray(final ArrayList<SubscriberPosition> subscriberPositions, final long nowNs) {
final int size = subscriberPositions.size();
final ReadablePosition[] positions = new ReadablePosition[subscriberPositions.size()];
for (int i = 0; i < size; i++) {
final SubscriberPosition subscriberPosition = subscriberPositions.get(i);
positions[i] = subscriberPosition.position();
if (!subscriberPosition.subscription().isTether()) {
untetheredSubscriptions.add(new UntetheredSubscription(subscriberPosition.subscription(), subscriberPosition.position(), nowNs));
}
}
return positions;
}
use of org.agrona.concurrent.status.ReadablePosition in project Aeron by real-logic.
the class IpcPublication method updatePublisherLimit.
int updatePublisherLimit() {
int workCount = 0;
if (State.ACTIVE == state) {
if (subscriberPositions.length > 0) {
long minSubscriberPosition = Long.MAX_VALUE;
long maxSubscriberPosition = consumerPosition;
for (final ReadablePosition subscriberPosition : subscriberPositions) {
final long position = subscriberPosition.getVolatile();
minSubscriberPosition = Math.min(minSubscriberPosition, position);
maxSubscriberPosition = Math.max(maxSubscriberPosition, position);
}
if (maxSubscriberPosition > consumerPosition) {
consumerPosition = maxSubscriberPosition;
}
final long proposedLimit = minSubscriberPosition + termWindowLength;
if (proposedLimit > tripLimit) {
cleanBufferTo(minSubscriberPosition);
publisherLimit.setOrdered(proposedLimit);
tripLimit = proposedLimit + tripGain;
workCount = 1;
}
} else if (publisherLimit.get() > consumerPosition) {
tripLimit = consumerPosition;
publisherLimit.setOrdered(consumerPosition);
cleanBufferTo(consumerPosition);
}
}
return workCount;
}
use of org.agrona.concurrent.status.ReadablePosition in project Aeron by real-logic.
the class SubscriptionLink method close.
/**
* {@inheritDoc}
*/
public void close() {
for (final Map.Entry<Subscribable, ReadablePosition> entry : positionBySubscribableMap.entrySet()) {
final Subscribable subscribable = entry.getKey();
final ReadablePosition position = entry.getValue();
subscribable.removeSubscriber(this, position);
}
}
Aggregations