summaryrefslogtreecommitdiff
path: root/java/src/Ice/src/main/java/IceInternal/DispatchWorkItem.java
diff options
context:
space:
mode:
Diffstat (limited to 'java/src/Ice/src/main/java/IceInternal/DispatchWorkItem.java')
-rw-r--r--java/src/Ice/src/main/java/IceInternal/DispatchWorkItem.java44
1 files changed, 44 insertions, 0 deletions
diff --git a/java/src/Ice/src/main/java/IceInternal/DispatchWorkItem.java b/java/src/Ice/src/main/java/IceInternal/DispatchWorkItem.java
new file mode 100644
index 00000000000..32eb98a6f9f
--- /dev/null
+++ b/java/src/Ice/src/main/java/IceInternal/DispatchWorkItem.java
@@ -0,0 +1,44 @@
+// **********************************************************************
+//
+// Copyright (c) 2003-2014 ZeroC, Inc. All rights reserved.
+//
+// This copy of Ice is licensed to you under the terms described in the
+// ICE_LICENSE file included in this distribution.
+//
+// **********************************************************************
+
+package IceInternal;
+
+//
+// A helper class for thread pool work items that only need to call user
+// callbacks. If a dispatcher is installed with the communicator, the
+// thread pool work item is executed with the dispatcher, otherwise it's
+// executed by a thread pool thread (after promoting a follower thread).
+//
+abstract public class DispatchWorkItem implements ThreadPoolWorkItem, Runnable
+{
+ public DispatchWorkItem()
+ {
+ }
+
+ public DispatchWorkItem(Ice.Connection connection)
+ {
+ _connection = connection;
+ }
+
+ @Override
+ final public void
+ execute(ThreadPoolCurrent current)
+ {
+ current.ioCompleted(); // Promote a follower
+ current.dispatchFromThisThread(this);
+ }
+
+ public Ice.Connection
+ getConnection()
+ {
+ return _connection;
+ }
+
+ private Ice.Connection _connection;
+}