
io.jsync.streams.WriteStream Maven / Gradle / Ivy
Show all versions of jsync.io Show documentation
/*
* Copyright (c) 2011-2013 The original author or authors
* ------------------------------------------------------
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* and Apache License v2.0 which accompanies this distribution.
*
* The Eclipse Public License is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* The Apache License v2.0 is available at
* http://www.opensource.org/licenses/apache2.0.php
*
* You may elect to redistribute this code under either of these licenses.
*/
package io.jsync.streams;
import io.jsync.buffer.Buffer;
/**
* Represents a stream of data that can be written to
* Any class that implements this interface can be used by a {@link Pump} to pump data from a {@code ReadStream}
* to it.
* This interface exposes a fluent api and the type T represents the type of the object that implements
* the interface to allow method chaining
*
* @author Tim Fox
*/
public interface WriteStream extends ExceptionSupport, DrainSupport {
/**
* Write some data to the stream. The data is put on an internal write queue, and the write actually happens
* asynchronously. To avoid running out of memory by putting too much on the write queue,
* check the {@link #writeQueueFull} method before writing. This is done automatically if using a {@link Pump}.
*/
T write(Buffer data);
}