summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorEike Stepper2006-10-23 15:06:54 (EDT)
committerEike Stepper2006-10-23 15:06:54 (EDT)
commitbb8c3765a13a93cb90777b8a59d660bb75d0372e (patch)
tree060fff1be284ea16b90a8f0fef914cfbbe45f770
parent08904699fd314ea52d7b12fbad7866b9192f2483 (diff)
downloadcdo-bb8c3765a13a93cb90777b8a59d660bb75d0372e.zip
cdo-bb8c3765a13a93cb90777b8a59d660bb75d0372e.tar.gz
cdo-bb8c3765a13a93cb90777b8a59d660bb75d0372e.tar.bz2
Signal protocol
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java5
-rw-r--r--plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java22
2 files changed, 23 insertions, 4 deletions
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java
index 820e97a..b8dffa1 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalActor.java
@@ -12,12 +12,15 @@ package org.eclipse.net4j.signal;
import org.eclipse.net4j.transport.BufferHandler;
import org.eclipse.net4j.transport.Channel;
+import org.eclipse.net4j.util.stream.BufferInputStream;
/**
* @author Eike Stepper
*/
public abstract class SignalActor<RESULT> extends Signal
{
+ public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
+
private boolean terminated;
private RESULT result;
@@ -31,7 +34,7 @@ public abstract class SignalActor<RESULT> extends Signal
public RESULT send() throws Exception
{
- return send(0);
+ return send(NO_TIMEOUT);
}
public RESULT send(long timeout) throws Exception
diff --git a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
index 01a4dab..74b359a 100644
--- a/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
+++ b/plugins/org.eclipse.net4j/src/org/eclipse/net4j/signal/SignalProtocol.java
@@ -30,6 +30,8 @@ import java.util.concurrent.ExecutorService;
*/
public abstract class SignalProtocol extends AbstractProtocol
{
+ public static final long NO_TIMEOUT = BufferInputStream.NO_TIMEOUT;
+
private static final int MIN_CORRELATION_ID = 1;
private static final int MAX_CORRELATION_ID = Integer.MAX_VALUE;
@@ -76,7 +78,7 @@ public abstract class SignalProtocol extends AbstractProtocol
signal = createSignalReactor(signalID);
signal.setProtocol(this);
signal.setCorrelationID(-correlationID);
- signal.setInputStream(new SignalInputStream());
+ signal.setInputStream(new SignalInputStream(getInputStreamTimeout()));
signal.setOutputStream(new SignalOutputStream(-correlationID, signalID, false));
signals.put(-correlationID, signal);
executorService.execute(signal);
@@ -96,6 +98,11 @@ public abstract class SignalProtocol extends AbstractProtocol
signal.getInputStream().handleBuffer(buffer);
}
+ public long getInputStreamTimeout()
+ {
+ return NO_TIMEOUT;
+ }
+
@Override
public String toString()
{
@@ -113,7 +120,7 @@ public abstract class SignalProtocol extends AbstractProtocol
short signalID = signalActor.getSignalID();
int correlationID = signalActor.getCorrelationID();
- signalActor.setInputStream(new SignalInputStream());
+ signalActor.setInputStream(new SignalInputStream(timeout));
signalActor.setOutputStream(new SignalOutputStream(correlationID, signalID, true));
signals.put(correlationID, signalActor);
@@ -144,8 +151,17 @@ public abstract class SignalProtocol extends AbstractProtocol
class SignalInputStream extends BufferInputStream
{
- public SignalInputStream()
+ private long timeout;
+
+ public SignalInputStream(long timeout)
+ {
+ this.timeout = timeout;
+ }
+
+ @Override
+ public long getMillisBeforeTimeout()
{
+ return timeout;
}
}