Package DebTorrent :: Module piecebuffer :: Class SingleBuffer
[hide private]
[frames] | no frames]

Class SingleBuffer

source code

A single piece buffer.

Instance Methods [hide private]
 
__init__(self, pool, count)
Initialize the instance.
source code
 
init(self)
Initialize the new piece buffer.
source code
 
append(self, s)
Add new data to the end of the buffer.
source code
int
__len__(self)
Get the length of the buffer.
source code
array.array
__getslice__(self, a, b)
Get a slice of data from the buffer.
source code
array.array
getarray(self)
Get al the data from the buffer.
source code
 
release(self)
Release this buffer to the pool for reuse.
source code
Instance Variables [hide private]
array.array buf
the character buffer used to store the piece
int length
the amount of data in the piece buffer
BufferPool pool
the pool of all piece buffers
Method Details [hide private]

__init__(self, pool, count)
(Constructor)

source code 
Initialize the instance.
Parameters:
  • pool (BufferPool) - the pool of all piece buffers
  • count (BufferPool) - the pool of all piece buffers

append(self, s)

source code 
Add new data to the end of the buffer.
Parameters:
  • s (string) - the new data to add

__len__(self)
(Length operator)

source code 
Get the length of the buffer.
Returns: int
the length of the data in the buffer

__getslice__(self, a, b)
(Slicling operator)

source code 
Get a slice of data from the buffer.
Parameters:
  • a (int) - the starting offset to get data from
  • b (int) - the ending offset to stop getting data at, can be negative to count from the end of the buffer
Returns: array.array
the requested data from the buffer

getarray(self)

source code 
Get al the data from the buffer.
Returns: array.array
the requested data from the buffer