class Piece extends Object implements Comparable<Piece>
Constructor and Description |
---|
Piece(int id) |
Modifier and Type | Method and Description |
---|---|
boolean |
addPeer(Peer peer)
caller must synchronize
|
void |
clear()
Clear all knowledge of peers
Caller must synchronize
|
int |
compareTo(Piece op)
Highest priority first,
then rarest first
|
boolean |
equals(Object o) |
int |
getId() |
int |
getPeerCount()
How many peers have this piece?
Caller must synchronize
|
int |
getPriority() |
int |
getRequestCount()
How many peers are requesting this piece?
Caller must synchronize
|
int |
hashCode() |
boolean |
isDisabled() |
boolean |
isRequested()
caller must synchronize
|
boolean |
isRequestedBy(Peer peer)
Is peer requesting this piece?
Caller must synchronize
|
boolean |
removePeer(Peer peer)
Caller must synchronize.
|
void |
setDisabled() |
void |
setPriority(int p) |
void |
setRequested(Peer peer,
boolean requested)
Since 0.8.3, keep track of who is requesting here,
to avoid deadlocks from querying each peer.
|
String |
toString() |
public int compareTo(Piece op)
compareTo
in interface Comparable<Piece>
public int getId()
public boolean addPeer(Peer peer)
public boolean removePeer(Peer peer)
public int getPeerCount()
public boolean isRequested()
public void setRequested(Peer peer, boolean requested)
public boolean isRequestedBy(Peer peer)
public int getRequestCount()
public void clear()
public int getPriority()
public void setPriority(int p)
public boolean isDisabled()
public void setDisabled()