Class MultiPeerUploader
java.lang.Object
com.biglybt.core.networkmanager.impl.MultiPeerUploader
- All Implemented Interfaces:
RateControlledEntity
A rate-controlled write entity backed by multiple peer connections, with an
emphasis on transmitting packets with full payloads, i.e. it writes to the
transport in mss-sized chunks if at all possible. It also employs fair,
round-robin write scheduling, where connections each take turns writing a
single full packet per round.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionprivate static class
Does this entity have data ready for writing. -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate boolean
private static final int
private static final int
private long
(package private) final AEMonitor
private final RateHandler
private final LinkedList<NetworkConnectionBase>
private EventWaiter
(package private) final HashMap<NetworkConnectionBase,
MultiPeerUploader.PeerData> Fields inherited from interface com.biglybt.core.networkmanager.impl.RateControlledEntity
PRIORITY_HIGH, PRIORITY_NORMAL
-
Constructor Summary
ConstructorsConstructorDescriptionMultiPeerUploader
(RateHandler rate_handler) Create a new packet-filling multi-peer upload entity, rate-controlled by the given handler. -
Method Summary
Modifier and TypeMethodDescriptionvoid
addPeerConnection
(NetworkConnectionBase peer_connection) Add the given connection to be managed by this upload entity.(package private) void
private void
boolean
canProcess
(EventWaiter waiter) Is ready for a processing op.void
destroy()
Destroy this upload entity.int
doProcessing
(EventWaiter waiter, int max_bytes) Attempt to do a processing operation.private void
Checks the connections in the waiting list to see if it's time to be force-flushed.long
int
getConnectionCount
(EventWaiter _waiter) If there are no connections then the waiter will be kicked when a connection arrivesint
Get this entity's priority level.boolean
stats functionsint
getReadyConnectionCount
(EventWaiter waiter) The waiter is kicked if the ready condition changesboolean
removePeerConnection
(NetworkConnectionBase peer_connection) Remove the given connection from this upload entity.private int
write
(EventWaiter waiter, int num_bytes_to_write, boolean protocol_is_free)
-
Field Details
-
FLUSH_CHECK_LOOP_TIME
private static final int FLUSH_CHECK_LOOP_TIME- See Also:
-
FLUSH_WAIT_TIME
private static final int FLUSH_WAIT_TIME- See Also:
-
last_flush_check_time
private long last_flush_check_time -
rate_handler
-
destroyed
private boolean destroyed -
waiting_connections
-
ready_connections
-
lists_lock
-
waiter
-
-
Constructor Details
-
MultiPeerUploader
Create a new packet-filling multi-peer upload entity, rate-controlled by the given handler.- Parameters:
rate_handler
- listener to handle upload rate limits
-
-
Method Details
-
getRateHandler
- Specified by:
getRateHandler
in interfaceRateControlledEntity
-
flushCheck
private void flushCheck()Checks the connections in the waiting list to see if it's time to be force-flushed. -
destroy
public void destroy()Destroy this upload entity. Note: Removes all peer connections in the process. -
addPeerConnection
Add the given connection to be managed by this upload entity.- Parameters:
peer_connection
- to be write managed
-
removePeerConnection
Remove the given connection from this upload entity.- Parameters:
peer_connection
- to be removed- Returns:
- true if the connection was found and removed, false if not removed
-
addToWaitingList
-
addToReadyList
-
write
-
getBytesReadyToWrite
public long getBytesReadyToWrite()- Specified by:
getBytesReadyToWrite
in interfaceRateControlledEntity
-
getConnectionCount
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
Description copied from interface:RateControlledEntity
The waiter is kicked if the ready condition changes- Specified by:
getReadyConnectionCount
in interfaceRateControlledEntity
- Returns:
-
canProcess
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
-
doProcessing
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
- Specified by:
getString
in interfaceRateControlledEntity
-