net.sf.asyncobjects.io
Class BufferedOutput<D extends BatchedData<D>,O extends AOutput<D>>

java.lang.Object
  extended by net.sf.asyncobjects.AsyncUnicastServer<O>
      extended by net.sf.asyncobjects.io.BufferedOutput<D,O>
Type Parameters:
D - a batched data type
O - an output type
All Implemented Interfaces:
ACloseable, AsyncObject, ExplicitSharing, AOutput<D>
Direct Known Subclasses:
BufferedByteOutput, BufferedTextOutput

public class BufferedOutput<D extends BatchedData<D>,O extends AOutput<D>>
extends AsyncUnicastServer<O>
implements AOutput<D>

Buffered output. The output waits util data will surpass specified limit, and only after it it writes bulk of the data. The write to underlying stream could be forced with AOutput.flush()

Author:
const

Constructor Summary
BufferedOutput(O output, int limit)
          A constructor from stream and buffer size
 
Method Summary
 Promise<Void> close()
          register close request and possibly execute it.
 Promise<Void> flush()
          Flush data in stream, upon return of this method all data will be written out to most underlying layer
 Promise<Void> write(D data)
          write data
 
Methods inherited from class net.sf.asyncobjects.AsyncUnicastServer
dereference, export, isImmediate, myVat, promise
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface net.sf.asyncobjects.AsyncObject
dereference, isImmediate
 

Constructor Detail

BufferedOutput

public BufferedOutput(O output,
                      int limit)
A constructor from stream and buffer size

Parameters:
output - an underlying output stream
limit - a limit, after limit is surpassed, data is sent to underlying stream
Method Detail

write

public Promise<Void> write(D data)
write data

Specified by:
write in interface AOutput<D extends BatchedData<D>>
Parameters:
data - data to write out
Returns:
promise that resolves when buffer finished to be written out
See Also:
AOutput.write(BatchedData)

flush

public Promise<Void> flush()
Description copied from interface: AOutput
Flush data in stream, upon return of this method all data will be written out to most underlying layer

Specified by:
flush in interface AOutput<D extends BatchedData<D>>
Returns:
a promise that resolves when flush finishes
See Also:
AOutput.flush()

close

public Promise<Void> close()
register close request and possibly execute it.

Specified by:
close in interface ACloseable
Returns:
a promise that resolves when stream is closed.
See Also:
ACloseable.close()


Copyright © 2002-2007 Constantine Plotnikov. All Rights Reserved.