Search in sources :

Example 1 with PluginLimitedRateGroup

use of com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup in project BiglyBT by BiglySoftware.

the class PeerImpl method closed.

protected void closed() {
    synchronized (this) {
        closed = true;
        if (up_rg_listener != null) {
            // tidy up
            LimitedRateGroup[] limiters = delegate.getRateLimiters(true);
            for (LimitedRateGroup l : limiters) {
                if (l instanceof PluginLimitedRateGroup) {
                    ((PluginLimitedRateGroup) l).removeListener(up_rg_listener);
                }
                delegate.removeRateLimiter(l, true);
            }
            limiters = delegate.getRateLimiters(false);
            for (LimitedRateGroup l : limiters) {
                if (l instanceof PluginLimitedRateGroup) {
                    ((PluginLimitedRateGroup) l).removeListener(down_rg_listener);
                }
                delegate.removeRateLimiter(l, false);
            }
        }
    }
    if (delegate instanceof PeerForeignDelegate) {
        ((PeerForeignDelegate) delegate).stop();
    }
}
Also used : PluginLimitedRateGroup(com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup) PluginLimitedRateGroup(com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup) LimitedRateGroup(com.biglybt.core.networkmanager.LimitedRateGroup)

Example 2 with PluginLimitedRateGroup

use of com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup in project BiglyBT by BiglySoftware.

the class PeerImpl method removeRateLimiter.

@Override
public void removeRateLimiter(RateLimiter limiter, boolean is_upload) {
    synchronized (this) {
        PluginLimitedRateGroup wrapped_limiter = UtilitiesImpl.wrapLimiter(limiter, true);
        if (up_rg_listener != null) {
            if (is_upload) {
                wrapped_limiter.removeListener(up_rg_listener);
            } else {
                wrapped_limiter.removeListener(down_rg_listener);
            }
        }
        delegate.removeRateLimiter(wrapped_limiter, is_upload);
    }
}
Also used : PluginLimitedRateGroup(com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup)

Example 3 with PluginLimitedRateGroup

use of com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup in project BiglyBT by BiglySoftware.

the class PeerImpl method getRateLimiters.

@Override
public RateLimiter[] getRateLimiters(boolean is_upload) {
    LimitedRateGroup[] limiters = delegate.getRateLimiters(is_upload);
    RateLimiter[] result = new RateLimiter[limiters.length];
    int pos = 0;
    for (LimitedRateGroup l : limiters) {
        if (l instanceof PluginLimitedRateGroup) {
            result[pos++] = UtilitiesImpl.unwrapLmiter((PluginLimitedRateGroup) l);
        }
    }
    if (pos == result.length) {
        return (result);
    }
    RateLimiter[] result_mod = new RateLimiter[pos];
    System.arraycopy(result, 0, result_mod, 0, pos);
    return (result_mod);
}
Also used : PluginLimitedRateGroup(com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup) RateLimiter(com.biglybt.pif.network.RateLimiter) PluginLimitedRateGroup(com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup) LimitedRateGroup(com.biglybt.core.networkmanager.LimitedRateGroup)

Example 4 with PluginLimitedRateGroup

use of com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup in project BiglyBT by BiglySoftware.

the class PeerImpl method addRateLimiter.

@Override
public void addRateLimiter(RateLimiter limiter, boolean is_upload) {
    synchronized (this) {
        if (closed) {
            return;
        }
        PluginLimitedRateGroup wrapped_limiter = UtilitiesImpl.wrapLimiter(limiter, true);
        if (up_rg_listener == null) {
            createRGListeners();
        }
        if (is_upload) {
            wrapped_limiter.addListener(up_rg_listener);
        } else {
            wrapped_limiter.addListener(down_rg_listener);
        }
        delegate.addRateLimiter(wrapped_limiter, is_upload);
    }
}
Also used : PluginLimitedRateGroup(com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup)

Aggregations

PluginLimitedRateGroup (com.biglybt.pifimpl.local.utils.UtilitiesImpl.PluginLimitedRateGroup)4 LimitedRateGroup (com.biglybt.core.networkmanager.LimitedRateGroup)2 RateLimiter (com.biglybt.pif.network.RateLimiter)1