E - The type of the entries.@ThreadSafe public class ConcurrentOutputShop<E extends Entry> extends DecoratingOutputShop<E,OutputShop<E>>
OutputShop to add accounting and multithreading
synchronization for all output streams created by the decorated output shop.ConcurrentInputShop| Modifier and Type | Class and Description |
|---|---|
private class |
ConcurrentOutputShop.ConcurrentOutputStream |
private class |
ConcurrentOutputShop.SynchronizedConcurrentOutputStream |
| Modifier and Type | Field and Description |
|---|---|
private static String |
CLASS_NAME |
private boolean |
closed |
private static Logger |
logger |
private Map<Closeable,Thread> |
threads
The pool of all open entry streams.
|
delegate| Constructor and Description |
|---|
ConcurrentOutputShop(OutputShop<E> output)
Constructs a concurrent output shop.
|
| Modifier and Type | Method and Description |
|---|---|
private void |
assertNotShopClosed()
Needs to be externally synchronized!
|
void |
close()
Closes this concurrent output shop.
|
<X extends Exception> |
closeAll(ExceptionHandler<IOException,X> handler)
Closes and disconnects all entry output streams created by this
concurrent output shop.
|
OutputSocket<? extends E> |
getOutputSocket(E entry)
Returns an output socket for writing to the given entry.
|
private int |
threadStreams()
Returns the number of streams opened by the current thread.
|
int |
waitCloseOthers(long timeout)
Waits until all entry output streams which have been opened by other
threads get closed or a timeout occurs.
|
getEntry, getSize, iterator, toStringclone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetEntry, getSize, iteratorprivate static final String CLASS_NAME
private static final Logger logger
private final Map<Closeable,Thread> threads
OutputBusyException
in case a sloppy client application has forgot to close a stream before
this output shop gets closed.private volatile boolean closed
public ConcurrentOutputShop(OutputShop<E> output)
output - the shop to decorate.NullPointerException - if output is null.public final int waitCloseOthers(long timeout)
java.util.logging and
this method returns.
Unless otherwise prevented, another thread could immediately open another stream upon return of this method. So there is actually no guarantee that really all streams are closed upon return of this method - use carefully!
private int threadStreams()
public final <X extends Exception> void closeAll(ExceptionHandler<IOException,X> handler) throws X extends Exception
IOException, with the exception of
their close() method.X extends Exceptionpublic final void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableclose in class DecoratingOutputShop<E extends Entry,OutputShop<E extends Entry>>IllegalStateException - If any open output streams are detected.IOExceptioncloseAll(de.schlichtherle.truezip.util.ExceptionHandler<java.io.IOException, X>)private void assertNotShopClosed()
throws IOException
IOExceptionpublic final OutputSocket<? extends E> getOutputSocket(E entry)
OutputServicegetOutputSocket in interface OutputService<E extends Entry>getOutputSocket in class DecoratingOutputShop<E extends Entry,OutputShop<E extends Entry>>entry - the entry, which will be the
local target of the returned
output socket.Copyright © 2005-2011 Schlichtherle IT Services. All Rights Reserved.