]> Sergey Matveev's repositories - btrtrc.git/blobdiff - piece.go
Make Torrent.pendingPieces a priority bitmap in preparation for #220
[btrtrc.git] / piece.go
index d5130d7b734d20bb45b075fc3b1eb15de5ba9a93..71c6041787289e217d4db4a39057dc3a7a85adfb 100644 (file)
--- a/piece.go
+++ b/piece.go
@@ -21,13 +21,20 @@ func (pp *piecePriority) Raise(maybe piecePriority) {
        }
 }
 
+// Priority for use in PriorityBitmap
+func (me piecePriority) BitmapPriority() int {
+       return -int(me)
+}
+
 const (
        PiecePriorityNone      piecePriority = iota // Not wanted.
        PiecePriorityNormal                         // Wanted.
+       PiecePriorityHigh                           // Wanted a lot.
        PiecePriorityReadahead                      // May be required soon.
-       // Succeeds a piece where a read occurred. Currently the same as Now, apparently due to issues with caching.
+       // Succeeds a piece where a read occurred. Currently the same as Now,
+       // apparently due to issues with caching.
        PiecePriorityNext
-       PiecePriorityNow // A Reader is reading in this piece.
+       PiecePriorityNow // A Reader is reading in this piece. Highest urgency.
 )
 
 type Piece struct {