com.alachisoft.ncache.client.internal.communication.RequestInformation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ncache-professional-client Show documentation
Show all versions of ncache-professional-client Show documentation
NCache Professional client for java.
package com.alachisoft.ncache.client.internal.communication;
class RequestInformation {
private final Object _mutex = new Object();
private java.util.HashSet _threadIds;
private int _requestsPerSecond;
private int _bulkThreshold;
private boolean _bulkingEnabled = false;
public RequestInformation() {
_threadIds = new java.util.HashSet();
_requestsPerSecond = 0;
}
public final void AddRequest() {
synchronized (_mutex) {
_threadIds.add(Thread.currentThread().getId());
_requestsPerSecond++;
}
}
public final boolean getBulkingEnabled() {
synchronized (_mutex) {
return _bulkingEnabled;
}
}
public final int getBulkThreshold() {
synchronized (_mutex) {
return _bulkThreshold;
}
}
public final void UpdateBulkThreshold() {
synchronized (_mutex) {
_bulkThreshold = _threadIds.size();
_bulkingEnabled = _threadIds.size() >= Runtime.getRuntime().availableProcessors();
_threadIds.clear();
_requestsPerSecond = 0;
}
}
}