Class MultiPeerDownloader2
- java.lang.Object
-
- com.biglybt.core.networkmanager.impl.MultiPeerDownloader2
-
- All Implemented Interfaces:
RateControlledEntity
public class MultiPeerDownloader2 extends java.lang.Object implements RateControlledEntity
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static class
MultiPeerDownloader2.connectionEntry
protected static class
MultiPeerDownloader2.connectionList
-
Field Summary
Fields Modifier and Type Field Description private MultiPeerDownloader2.connectionList
active_connections
private static java.lang.Object
ADD_ACTION
private java.util.ArrayList
connections_cow
private AEMonitor
connections_mon
private MultiPeerDownloader2.connectionList
idle_connections
private long
last_idle_check
private RateHandler
main_handler
private static int
MOVE_TO_IDLE_TIME
private java.util.List
pending_actions
private static java.lang.Object
REMOVE_ACTION
private EventWaiter
waiter
-
Fields inherited from interface com.biglybt.core.networkmanager.impl.RateControlledEntity
PRIORITY_HIGH, PRIORITY_NORMAL
-
-
Constructor Summary
Constructors Constructor Description MultiPeerDownloader2(RateHandler _main_handler)
Create new downloader using the given "global" rate handler to limit all peers managed by this downloader.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
addPeerConnection(NetworkConnectionBase connection)
Add the given connection to the downloader.boolean
canProcess(EventWaiter waiter)
Is ready for a processing op.int
doProcessing(EventWaiter waiter, int max_bytes)
Attempt to do a processing operation.long
getBytesReadyToWrite()
int
getConnectionCount(EventWaiter _waiter)
If there are no connections then the waiter will be kicked when a connection arrivesint
getPriority()
Get this entity's priority level.boolean
getPriorityBoost()
stats functionsRateHandler
getRateHandler()
int
getReadyConnectionCount(EventWaiter waiter)
The waiter is kicked if the ready condition changesjava.lang.String
getString()
boolean
removePeerConnection(NetworkConnectionBase connection)
Remove the given connection from the downloader.
-
-
-
Field Detail
-
MOVE_TO_IDLE_TIME
private static final int MOVE_TO_IDLE_TIME
- See Also:
- Constant Field Values
-
ADD_ACTION
private static final java.lang.Object ADD_ACTION
-
REMOVE_ACTION
private static final java.lang.Object REMOVE_ACTION
-
connections_cow
private volatile java.util.ArrayList connections_cow
-
connections_mon
private final AEMonitor connections_mon
-
main_handler
private final RateHandler main_handler
-
pending_actions
private java.util.List pending_actions
-
active_connections
private final MultiPeerDownloader2.connectionList active_connections
-
idle_connections
private final MultiPeerDownloader2.connectionList idle_connections
-
last_idle_check
private long last_idle_check
-
waiter
private volatile EventWaiter waiter
-
-
Constructor Detail
-
MultiPeerDownloader2
public MultiPeerDownloader2(RateHandler _main_handler)
Create new downloader using the given "global" rate handler to limit all peers managed by this downloader.- Parameters:
main_handler
-
-
-
Method Detail
-
getRateHandler
public RateHandler getRateHandler()
- Specified by:
getRateHandler
in interfaceRateControlledEntity
-
addPeerConnection
public void addPeerConnection(NetworkConnectionBase connection)
Add the given connection to the downloader.- Parameters:
connection
- to add
-
removePeerConnection
public boolean removePeerConnection(NetworkConnectionBase connection)
Remove the given connection from the downloader.- Parameters:
connection
- to remove- Returns:
- true if the connection was found and removed, false if not removed
-
canProcess
public boolean canProcess(EventWaiter waiter)
Description copied from interface:RateControlledEntity
Is ready for a processing op.- Specified by:
canProcess
in interfaceRateControlledEntity
- Returns:
- true if it can process >0 bytes, false if not ready
-
getBytesReadyToWrite
public long getBytesReadyToWrite()
- Specified by:
getBytesReadyToWrite
in interfaceRateControlledEntity
-
getConnectionCount
public int getConnectionCount(EventWaiter _waiter)
Description copied from interface:RateControlledEntity
If there are no connections then the waiter will be kicked when a connection arrives- Specified by:
getConnectionCount
in interfaceRateControlledEntity
- Returns:
-
getReadyConnectionCount
public int getReadyConnectionCount(EventWaiter waiter)
Description copied from interface:RateControlledEntity
The waiter is kicked if the ready condition changes- Specified by:
getReadyConnectionCount
in interfaceRateControlledEntity
- Returns:
-
doProcessing
public int doProcessing(EventWaiter waiter, int max_bytes)
Description copied from interface:RateControlledEntity
Attempt to do a processing operation.- Specified by:
doProcessing
in interfaceRateControlledEntity
- Returns:
- true if >0 bytes were processed (success), false if 0 bytes were processed (failure)
-
getPriority
public int getPriority()
Description copied from interface:RateControlledEntity
Get this entity's priority level.- Specified by:
getPriority
in interfaceRateControlledEntity
- Returns:
- priority
-
getPriorityBoost
public boolean getPriorityBoost()
Description copied from interface:RateControlledEntity
stats functions- Specified by:
getPriorityBoost
in interfaceRateControlledEntity
- Returns:
-
getString
public java.lang.String getString()
- Specified by:
getString
in interfaceRateControlledEntity
-
-