All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.client.internal.communication.RequestInformation Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
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;
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy