Class OutgoingBTHaveMessageAggregator
java.lang.Object
com.biglybt.core.peermanager.utils.OutgoingBTHaveMessageAggregator
Utility class to enable write aggregation of BT Have messages,
in order to save bandwidth by not wasting a whole network packet
on a single small 9-byte message, and instead pad them onto other
messages.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final OutgoingMessageQueue.MessageQueueListenerprivate byteprivate byteprivate booleanprivate final OutgoingMessageQueueprivate final ArrayListprivate final AEMonitor -
Constructor Summary
ConstructorsConstructorDescriptionOutgoingBTHaveMessageAggregator(OutgoingMessageQueue outgoing_message_q, byte _bt_have_version, byte _az_have_version) Create a new aggregator, which will send messages out the given queue. -
Method Summary
Modifier and TypeMethodDescriptionvoiddestroy()Destroy the aggregator, along with any pending messages.voidForce send of any aggregated/pending have messages.booleanAre there Haves messages pending?voidqueueHaveMessage(int piece_number, boolean force) Queue a new have message for aggregated sending.private voidvoidsetHaveVersion(byte bt_version, byte az_version)
-
Field Details
-
pending_haves
-
pending_haves_mon
-
bt_have_version
private byte bt_have_version -
az_have_version
private byte az_have_version -
destroyed
private boolean destroyed -
outgoing_message_q
-
added_message_listener
-
-
Constructor Details
-
OutgoingBTHaveMessageAggregator
public OutgoingBTHaveMessageAggregator(OutgoingMessageQueue outgoing_message_q, byte _bt_have_version, byte _az_have_version) Create a new aggregator, which will send messages out the given queue.- Parameters:
outgoing_message_q-
-
-
Method Details
-
setHaveVersion
public void setHaveVersion(byte bt_version, byte az_version) -
queueHaveMessage
public void queueHaveMessage(int piece_number, boolean force) Queue a new have message for aggregated sending.- Parameters:
piece_number- of the have messageforce- if true, send this and any other pending haves right away
-
destroy
public void destroy()Destroy the aggregator, along with any pending messages. -
forceSendOfPending
public void forceSendOfPending()Force send of any aggregated/pending have messages. -
hasPending
public boolean hasPending()Are there Haves messages pending?- Returns:
- true if there are any unsent haves, false otherwise
-
sendPendingHaves
private void sendPendingHaves()
-