java.lang.Object
net.i2p.sam.SAMStreamSession.StreamSender
net.i2p.sam.SAMv2StreamSession.V2StreamSender
- All Implemented Interfaces:
Runnable
- Enclosing class:
SAMv2StreamSession
Thread sending the v2 stream data.
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final ByteCacheCache supplying the chunk buffers.The data chunks waiting to be sent.private intTotal bytes queued in the chunks.private final OutputStreamStream the data is written to.private booleanTrue to drain the queue before closing.private booleanTrue while the sender thread runs.private final ObjectLock for the sender thread state.Constructor Summary
ConstructorsMethod Summary
All MethodsModifier and TypeMethodDescriptionvoidrun()Pumps pending outgoing data to the peer until the stream shuts down.voidsendBytes(InputStream in, int size) Send bytes through the SAM STREAM session socket sender.voidStop a SAM STREAM session socket sender gracefully: stop the sender thread once all pending data has been sent.voidStop a SAM STREAM session socket sender thread immediately.
Field Details
_data
_dataSize
private int _dataSizeTotal bytes queued in the chunks._cache
Cache supplying the chunk buffers._out
Stream the data is written to._stillRunning
private volatile boolean _stillRunningTrue while the sender thread runs._shuttingDownGracefully
private volatile boolean _shuttingDownGracefullyTrue to drain the queue before closing.runningLock
Lock for the sender thread state.
Constructor Details
V2StreamSender
Builds the sender for one stream session.- Parameters:
s- the socket the data is written toid- the id of the session- Throws:
IOException- if the socket's output stream cannot be opened
Method Details
sendBytes
Send bytes through the SAM STREAM session socket sender.- Specified by:
sendBytesin classSAMStreamSession.StreamSender- Parameters:
in- Data stream of data to sendsize- Count of bytes to send- Throws:
IOException- if the client didnt provide enough data
stopRunning
public void stopRunning()Stop a SAM STREAM session socket sender thread immediately.- Specified by:
stopRunningin classSAMStreamSession.StreamSender
shutDownGracefully
public void shutDownGracefully()Stop a SAM STREAM session socket sender gracefully: stop the sender thread once all pending data has been sent.- Specified by:
shutDownGracefullyin classSAMStreamSession.StreamSender
run
public void run()Pumps pending outgoing data to the peer until the stream shuts down.- Specified by:
runin interfaceRunnable- Specified by:
runin classSAMStreamSession.StreamSender