summaryrefslogtreecommitdiff
path: root/cppe/src/IceE/Outgoing.cpp
diff options
context:
space:
mode:
authorDwayne Boone <dwayne@zeroc.com>2005-12-13 17:03:20 +0000
committerDwayne Boone <dwayne@zeroc.com>2005-12-13 17:03:20 +0000
commit60858a33bbce82f8af38fa70d26fc46d771aece4 (patch)
treeccd38b1dd37803de6dffbf889053fe894db62188 /cppe/src/IceE/Outgoing.cpp
parentAdded replica group tests (diff)
downloadice-60858a33bbce82f8af38fa70d26fc46d771aece4.tar.bz2
ice-60858a33bbce82f8af38fa70d26fc46d771aece4.tar.xz
ice-60858a33bbce82f8af38fa70d26fc46d771aece4.zip
Removed sync from Outgoing for blocking sends
Diffstat (limited to 'cppe/src/IceE/Outgoing.cpp')
-rw-r--r--cppe/src/IceE/Outgoing.cpp143
1 files changed, 82 insertions, 61 deletions
diff --git a/cppe/src/IceE/Outgoing.cpp b/cppe/src/IceE/Outgoing.cpp
index c75ded2a4cc..c5561b62c7d 100644
--- a/cppe/src/IceE/Outgoing.cpp
+++ b/cppe/src/IceE/Outgoing.cpp
@@ -113,78 +113,94 @@ IceInternal::Outgoing::invoke()
{
case Reference::ModeTwoway:
{
- //
- // We let all exceptions raised by sending directly
- // propagate to the caller, because they can be retried
- // without violating "at-most-once". In case of such
- // exceptions, the connection object does not call back on
- // this object, so we don't need to lock the mutex, keep
- // track of state, or save exceptions.
- //
- _connection->sendRequest(&_os, this);
+#ifndef ICEE_PURE_BLOCKING_CLIENT
+#ifdef ICEE_BLOCKING_CLIENT
+ if(!_connection->blocking())
+ {
+#endif
+ //
+ // We let all exceptions raised by sending directly
+ // propagate to the caller, because they can be retried
+ // without violating "at-most-once". In case of such
+ // exceptions, the connection object does not call back on
+ // this object, so we don't need to lock the mutex, keep
+ // track of state, or save exceptions.
+ //
+ _connection->sendRequest(&_os, 0, this);
- //
- // Wait until the request has completed, or until the
- // request times out.
- //
+ //
+ // Wait until the request has completed, or until the
+ // request times out.
+ //
- bool timedOut = false;
+ bool timedOut = false;
- {
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+ {
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
- //
- // It's possible that the request has already
- // completed, due to a regular response, or because of
- // an exception. So we only change the state to "in
- // progress" if it is still "unsent".
- //
- if(_state == StateUnsent)
- {
- _state = StateInProgress;
- }
+ //
+ // It's possible that the request has already
+ // completed, due to a regular response, or because of
+ // an exception. So we only change the state to "in
+ // progress" if it is still "unsent".
+ //
+ if(_state == StateUnsent)
+ {
+ _state = StateInProgress;
+ }
- Int timeout = _connection->timeout();
- while(_state == StateInProgress && !timedOut)
- {
- if(timeout >= 0)
- {
- timedWait(IceUtil::Time::milliSeconds(timeout));
+ Int timeout = _connection->timeout();
+ while(_state == StateInProgress && !timedOut)
+ {
+ if(timeout >= 0)
+ {
+ timedWait(IceUtil::Time::milliSeconds(timeout));
- if(_state == StateInProgress)
- {
- timedOut = true;
- }
+ if(_state == StateInProgress)
+ {
+ timedOut = true;
+ }
+ }
+ else
+ {
+ wait();
+ }
}
- else
+ }
+
+ if(timedOut)
+ {
+ //
+ // Must be called outside the synchronization of this
+ // object.
+ //
+ _connection->exception(TimeoutException(__FILE__, __LINE__));
+
+ //
+ // We must wait until the exception set above has
+ // propagated to this Outgoing object.
+ //
{
- wait();
+ IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
+
+ while(_state == StateInProgress)
+ {
+ wait();
+ }
}
- }
+ }
+#ifdef ICEE_BLOCKING_CLIENT
}
-
- if(timedOut)
+ else
{
- //
- // Must be called outside the synchronization of this
- // object.
- //
- _connection->exception(TimeoutException(__FILE__, __LINE__));
-
- //
- // We must wait until the exception set above has
- // propagated to this Outgoing object.
- //
+ _connection->sendRequest(&_os, &_is, this);
+ if(!_exception.get())
{
- IceUtil::Monitor<IceUtil::Mutex>::Lock sync(*this);
-
- while(_state == StateInProgress)
- {
- wait();
- }
+ finishedInternal();
}
}
-
+#endif
+#endif
if(_exception.get())
{
//
@@ -232,7 +248,7 @@ IceInternal::Outgoing::invoke()
// violating "at-most-once".
//
_state = StateInProgress;
- _connection->sendRequest(&_os, 0);
+ _connection->sendRequest(&_os, 0, 0);
break;
}
@@ -297,6 +313,13 @@ IceInternal::Outgoing::finished(BasicStream& is)
assert(_state <= StateInProgress);
_is.swap(is);
+ finishedInternal();
+ notify();
+}
+
+void
+IceInternal::Outgoing::finishedInternal()
+{
Byte status;
_is.read(status);
@@ -449,8 +472,6 @@ IceInternal::Outgoing::finished(BasicStream& is)
break;
}
}
-
- notify();
}
void