public class Window extends AbstractLoggingBean implements Channel, ChannelHolder
Modifier and Type | Field and Description |
---|---|
static Predicate<Window> |
SPACE_AVAILABLE_PREDICATE
Default
Predicate used to test if space became available |
log
Constructor and Description |
---|
Window(AbstractChannel channel,
Object lock,
boolean client,
boolean local) |
Modifier and Type | Method and Description |
---|---|
void |
check(long maxFree) |
protected void |
checkInitialized(String location) |
void |
close() |
void |
consume(long len) |
void |
consumeAndCheck(long len) |
void |
expand(int window) |
AbstractChannel |
getChannel() |
long |
getMaxSize() |
long |
getPacketSize() |
long |
getSize() |
void |
init(long size,
long packetSize,
PropertyResolver resolver) |
void |
init(PropertyResolver resolver) |
boolean |
isOpen() |
String |
toString() |
protected void |
updateSize(long size) |
void |
waitAndConsume(long len,
long maxWaitTime)
Waits for enough data to become available to consume the specified size
|
protected void |
waitForCondition(Predicate<? super Window> predicate,
long maxWaitTime)
Waits up to a specified amount of time for a condition to be satisfied and
signaled via the lock.
|
long |
waitForSpace(long maxWaitTime)
Waits until some data becomes available or timeout expires
|
getSimplifiedLogger
public Window(AbstractChannel channel, Object lock, boolean client, boolean local)
public AbstractChannel getChannel()
getChannel
in interface ChannelHolder
Channel
instancepublic long getSize()
public long getMaxSize()
public long getPacketSize()
public void init(PropertyResolver resolver)
public void init(long size, long packetSize, PropertyResolver resolver)
public void expand(int window)
public void consume(long len)
public void consumeAndCheck(long len) throws IOException
IOException
public void check(long maxFree) throws IOException
IOException
public void waitAndConsume(long len, long maxWaitTime) throws InterruptedException, WindowClosedException, SocketTimeoutException
len
- Size of data to consumemaxWaitTime
- ax. time (millis) to wait for enough data to become availableInterruptedException
- If interrupted while waitingWindowClosedException
- If window closed while waitingSocketTimeoutException
- If timeout expired before enough data became availablewaitForCondition(Predicate, long)
,
consume(long)
public long waitForSpace(long maxWaitTime) throws InterruptedException, WindowClosedException, SocketTimeoutException
maxWaitTime
- Max. time (millis) to wait for space to become availableInterruptedException
- If interrupted while waitingWindowClosedException
- If window closed while waitingSocketTimeoutException
- If timeout expired before space became availablewaitForCondition(Predicate, long)
protected void waitForCondition(Predicate<? super Window> predicate, long maxWaitTime) throws WindowClosedException, InterruptedException, SocketTimeoutException
predicate
- The Predicate
to check if the condition has been
satisfied - the argument to the predicate is this
referencemaxWaitTime
- Max. time (millis) to wait for the condition to be satisfiedWindowClosedException
- If window closed while waitingInterruptedException
- If interrupted while waitingSocketTimeoutException
- If timeout expired before condition was satisfiedisOpen()
protected void updateSize(long size)
protected void checkInitialized(String location)
public void close() throws IOException
close
in interface Closeable
close
in interface AutoCloseable
close
in interface Channel
IOException
Copyright © 2008–2022 The Apache Software Foundation. All rights reserved.