|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object javaFlacEncoder.BlockThreadManager
public class BlockThreadManager
BlockThreadManager is used by FLACEncoder(when encoding with threads), to dispatch BlockEncodeRequests to ThreadFrames which do the actual encode. BlockThreadManager accepts BlockEncodeRequest objects to encode. For each Frame object given to encode with, a Thread is supplied. This thread will take a BlockEncodeRequest, encode it, then give it back to the BlockThreadManager The thread will then take another BlockencodeRequest, and repeat. If no block encode requests are available, it will block till available. The main thread of the BlockThreadManager will be waiting for additions to the finished queue. If the item is not the next in line to be written to file, it will be saved temporarily. If it is the next item to be written, it will be given back to the FLACEncoder to be written to output, and any saved objects will be searched to see if more can be written. The main thread will then wait for the next frame again.
Constructor Summary | |
---|---|
BlockThreadManager(FLACEncoder encoder)
Constructor. |
Method Summary | |
---|---|
boolean |
addFrameThread(Frame frame)
Add a Frame to this manager, which it will use to encode a block. |
boolean |
addRequest(BlockEncodeRequest ber)
Add a BlockEncodeRequest to the manager. |
void |
blockWhileQueueExceeds(int count)
This function is used to help control flow of BlockEncodeRequests into this manager. |
int |
getTotalManagedCount()
Get total number of BlockEncodeRequests added to this manager, but not yet passed back to the FLACEncoder object. |
BlockEncodeRequest |
getWaitingRequest()
Get a BlockEncodeRequest object which is queued for encoding, pausing for up to 0.5 seconds till one is available. |
void |
notifyFrameThreadExit(FrameThread ft)
Notify this manager that a FrameThread has ended it's run() method, returning the FrameThread object to the manager for use in future Threads. |
void |
returnFinishedRequest(BlockEncodeRequest ber)
Used to return a finished BlockEncodeRequest from a FrameThread. |
void |
run()
Waits for the next BlockEncodeRequest that needs to be sent back to the FLACEncoder for finalizing. |
void |
stop()
Notify this manager that it may stop as soon as all currently outstanding requests are completed. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BlockThreadManager(FLACEncoder encoder)
encoder
- FLACEncoder to use in encoding process.Method Detail |
---|
public int getTotalManagedCount()
public void blockWhileQueueExceeds(int count)
count
- Maximum number of outstanding requests that may exist before
this method may return.public boolean addFrameThread(Frame frame)
frame
- Frame to use for encoding.
public void notifyFrameThreadExit(FrameThread ft)
ft
- FrameThread object which is ending.public BlockEncodeRequest getWaitingRequest()
public void stop()
public void returnFinishedRequest(BlockEncodeRequest ber)
ber
- finished BlockEncodeRequest that needs passed back to the
FLACEncoder object.public void run()
run
in interface java.lang.Runnable
public boolean addRequest(BlockEncodeRequest ber)
ber
- Block request to encode
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |