summaryrefslogtreecommitdiff
path: root/java/src
diff options
context:
space:
mode:
authorMark Spruiell <mes@zeroc.com>2005-07-07 19:15:16 +0000
committerMark Spruiell <mes@zeroc.com>2005-07-07 19:15:16 +0000
commit72f0fe54fc96d9a9014b530db8f9987455d6f598 (patch)
tree092a29216d5d55e9ec2ec0d7e047a3a30f2d0239 /java/src
parentfixing mono compile error (diff)
downloadice-72f0fe54fc96d9a9014b530db8f9987455d6f598.tar.bz2
ice-72f0fe54fc96d9a9014b530db8f9987455d6f598.tar.xz
ice-72f0fe54fc96d9a9014b530db8f9987455d6f598.zip
cache Outgoing objects in connection instead of delegate
Diffstat (limited to 'java/src')
-rw-r--r--java/src/Ice/ConnectionI.java43
-rw-r--r--java/src/Ice/_ObjectDelM.java74
-rw-r--r--java/src/IceInternal/Outgoing.java7
3 files changed, 70 insertions, 54 deletions
diff --git a/java/src/Ice/ConnectionI.java b/java/src/Ice/ConnectionI.java
index 241ffb1f2be..7fec58c8ec7 100644
--- a/java/src/Ice/ConnectionI.java
+++ b/java/src/Ice/ConnectionI.java
@@ -2335,6 +2335,46 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
}
}
+ public IceInternal.Outgoing
+ getOutgoing(IceInternal.Reference reference, String operation, OperationMode mode, java.util.Map context,
+ boolean compress)
+ throws IceInternal.NonRepeatable
+ {
+ IceInternal.Outgoing out = null;
+
+ synchronized(_outgoingCacheMutex)
+ {
+ if(_outgoingCache == null)
+ {
+ out = new IceInternal.Outgoing(this, reference, operation, mode, context, compress);
+ }
+ else
+ {
+ out = _outgoingCache;
+ _outgoingCache = _outgoingCache.next;
+ out.reset(reference, operation, mode, context, compress);
+ out.next = null;
+ }
+ }
+
+ return out;
+ }
+
+ public void
+ reclaimOutgoing(IceInternal.Outgoing out)
+ {
+ //
+ // Clear references to Ice objects as soon as possible.
+ //
+ out.reclaim();
+
+ synchronized(_outgoingCacheMutex)
+ {
+ out.next = _outgoingCache;
+ _outgoingCache = out;
+ }
+ }
+
private class ThreadPerConnection extends Thread
{
public void
@@ -2399,6 +2439,9 @@ public final class ConnectionI extends IceInternal.EventHandler implements Conne
private IceInternal.Incoming _incomingCache;
private java.lang.Object _incomingCacheMutex = new java.lang.Object();
+ private IceInternal.Outgoing _outgoingCache;
+ private java.lang.Object _outgoingCacheMutex = new java.lang.Object();
+
private static boolean _compressionSupported = IceInternal.BasicStream.compressible();
private boolean _overrideCompress;
diff --git a/java/src/Ice/_ObjectDelM.java b/java/src/Ice/_ObjectDelM.java
index ecc7d390f8c..7ba99456070 100644
--- a/java/src/Ice/_ObjectDelM.java
+++ b/java/src/Ice/_ObjectDelM.java
@@ -15,13 +15,13 @@ public class _ObjectDelM implements _ObjectDel
ice_isA(String __id, java.util.Map __context)
throws IceInternal.NonRepeatable
{
- IceInternal.Outgoing __outS = getOutgoing("ice_isA", OperationMode.Nonmutating, __context);
+ IceInternal.Outgoing __og = getOutgoing("ice_isA", OperationMode.Nonmutating, __context);
try
{
- IceInternal.BasicStream __is = __outS.is();
- IceInternal.BasicStream __os = __outS.os();
+ IceInternal.BasicStream __is = __og.is();
+ IceInternal.BasicStream __os = __og.os();
__os.writeString(__id);
- if(!__outS.invoke())
+ if(!__og.invoke())
{
throw new UnknownUserException();
}
@@ -36,7 +36,7 @@ public class _ObjectDelM implements _ObjectDel
}
finally
{
- reclaimOutgoing(__outS);
+ reclaimOutgoing(__og);
}
}
@@ -44,17 +44,17 @@ public class _ObjectDelM implements _ObjectDel
ice_ping(java.util.Map __context)
throws IceInternal.NonRepeatable
{
- IceInternal.Outgoing __outS = getOutgoing("ice_ping", OperationMode.Nonmutating, __context);
+ IceInternal.Outgoing __og = getOutgoing("ice_ping", OperationMode.Nonmutating, __context);
try
{
- if(!__outS.invoke())
+ if(!__og.invoke())
{
throw new UnknownUserException();
}
}
finally
{
- reclaimOutgoing(__outS);
+ reclaimOutgoing(__og);
}
}
@@ -62,11 +62,11 @@ public class _ObjectDelM implements _ObjectDel
ice_ids(java.util.Map __context)
throws IceInternal.NonRepeatable
{
- IceInternal.Outgoing __outS = getOutgoing("ice_ids", OperationMode.Nonmutating, __context);
+ IceInternal.Outgoing __og = getOutgoing("ice_ids", OperationMode.Nonmutating, __context);
try
{
- IceInternal.BasicStream __is = __outS.is();
- if(!__outS.invoke())
+ IceInternal.BasicStream __is = __og.is();
+ if(!__og.invoke())
{
throw new UnknownUserException();
}
@@ -81,7 +81,7 @@ public class _ObjectDelM implements _ObjectDel
}
finally
{
- reclaimOutgoing(__outS);
+ reclaimOutgoing(__og);
}
}
@@ -89,11 +89,11 @@ public class _ObjectDelM implements _ObjectDel
ice_id(java.util.Map __context)
throws IceInternal.NonRepeatable
{
- IceInternal.Outgoing __outS = getOutgoing("ice_id", OperationMode.Nonmutating, __context);
+ IceInternal.Outgoing __og = getOutgoing("ice_id", OperationMode.Nonmutating, __context);
try
{
- IceInternal.BasicStream __is = __outS.is();
- if(!__outS.invoke())
+ IceInternal.BasicStream __is = __og.is();
+ if(!__og.invoke())
{
throw new UnknownUserException();
}
@@ -108,7 +108,7 @@ public class _ObjectDelM implements _ObjectDel
}
finally
{
- reclaimOutgoing(__outS);
+ reclaimOutgoing(__og);
}
}
@@ -116,20 +116,20 @@ public class _ObjectDelM implements _ObjectDel
ice_invoke(String operation, OperationMode mode, byte[] inParams, ByteSeqHolder outParams, java.util.Map __context)
throws IceInternal.NonRepeatable
{
- IceInternal.Outgoing __outS = getOutgoing(operation, mode, __context);
+ IceInternal.Outgoing __og = getOutgoing(operation, mode, __context);
try
{
if(inParams != null)
{
- IceInternal.BasicStream __os = __outS.os();
+ IceInternal.BasicStream __os = __og.os();
__os.writeBlob(inParams);
}
- boolean ok = __outS.invoke();
+ boolean ok = __og.invoke();
if(__reference.getMode() == IceInternal.Reference.ModeTwoway)
{
try
{
- IceInternal.BasicStream __is = __outS.is();
+ IceInternal.BasicStream __is = __og.is();
int sz = __is.getReadEncapsSize();
if(outParams != null)
{
@@ -145,7 +145,7 @@ public class _ObjectDelM implements _ObjectDel
}
finally
{
- reclaimOutgoing(__outS);
+ reclaimOutgoing(__og);
}
}
@@ -204,40 +204,12 @@ public class _ObjectDelM implements _ObjectDel
getOutgoing(String operation, OperationMode mode, java.util.Map context)
throws IceInternal.NonRepeatable
{
- IceInternal.Outgoing out = null;
-
- synchronized(__outgoingMutex)
- {
- if(__outgoingCache == null)
- {
- out = new IceInternal.Outgoing(__connection, __reference, operation, mode, context, __compress);
- }
- else
- {
- out = __outgoingCache;
- __outgoingCache = __outgoingCache.next;
- out.reset(operation, mode, context);
- out.next = null;
- }
- }
-
- return out;
+ return __connection.getOutgoing(__reference, operation, mode, context, __compress);
}
protected void
reclaimOutgoing(IceInternal.Outgoing out)
{
- synchronized(__outgoingMutex)
- {
- out.next = __outgoingCache;
- __outgoingCache = out;
- //
- // Clear references to Ice objects as soon as possible.
- //
- __outgoingCache.reclaim();
- }
+ __connection.reclaimOutgoing(out);
}
-
- private IceInternal.Outgoing __outgoingCache;
- private java.lang.Object __outgoingMutex = new java.lang.Object();
}
diff --git a/java/src/IceInternal/Outgoing.java b/java/src/IceInternal/Outgoing.java
index 1371fc76e5b..6640129de61 100644
--- a/java/src/IceInternal/Outgoing.java
+++ b/java/src/IceInternal/Outgoing.java
@@ -27,15 +27,16 @@ public final class Outgoing
}
//
- // These functions allow this object to be reused, rather than
- // reallocated.
+ // These functions allow this object to be reused, rather than reallocated.
//
public void
- reset(String operation, Ice.OperationMode mode, java.util.Map context)
+ reset(Reference ref, String operation, Ice.OperationMode mode, java.util.Map context, boolean compress)
throws NonRepeatable
{
+ _reference = ref;
_state = StateUnsent;
_exception = null;
+ _compress = compress;
writeHeader(operation, mode, context);
}