summaryrefslogtreecommitdiff
path: root/ACE/apps/JAWS3/jaws3
diff options
context:
space:
mode:
Diffstat (limited to 'ACE/apps/JAWS3/jaws3')
-rw-r--r--ACE/apps/JAWS3/jaws3/Asynch_IO.cpp308
-rw-r--r--ACE/apps/JAWS3/jaws3/Asynch_IO.h72
-rw-r--r--ACE/apps/JAWS3/jaws3/Asynch_IO_Helpers.h54
-rw-r--r--ACE/apps/JAWS3/jaws3/Cached_Allocator_T.cpp140
-rw-r--r--ACE/apps/JAWS3/jaws3/Cached_Allocator_T.h107
-rw-r--r--ACE/apps/JAWS3/jaws3/Concurrency.cpp105
-rw-r--r--ACE/apps/JAWS3/jaws3/Concurrency.h74
-rw-r--r--ACE/apps/JAWS3/jaws3/Concurrency_T.cpp47
-rw-r--r--ACE/apps/JAWS3/jaws3/Concurrency_T.h50
-rw-r--r--ACE/apps/JAWS3/jaws3/Config_File.cpp304
-rw-r--r--ACE/apps/JAWS3/jaws3/Config_File.h73
-rw-r--r--ACE/apps/JAWS3/jaws3/Datagram.cpp86
-rw-r--r--ACE/apps/JAWS3/jaws3/Datagram.h139
-rw-r--r--ACE/apps/JAWS3/jaws3/Event_Completer.cpp55
-rw-r--r--ACE/apps/JAWS3/jaws3/Event_Completer.h43
-rw-r--r--ACE/apps/JAWS3/jaws3/Event_Dispatcher.cpp52
-rw-r--r--ACE/apps/JAWS3/jaws3/Event_Dispatcher.h52
-rw-r--r--ACE/apps/JAWS3/jaws3/Event_Result.h104
-rw-r--r--ACE/apps/JAWS3/jaws3/Export.h48
-rw-r--r--ACE/apps/JAWS3/jaws3/FILE.cpp93
-rw-r--r--ACE/apps/JAWS3/jaws3/FILE.h50
-rw-r--r--ACE/apps/JAWS3/jaws3/IO.cpp114
-rw-r--r--ACE/apps/JAWS3/jaws3/IO.h140
-rw-r--r--ACE/apps/JAWS3/jaws3/Makefile.am138
-rw-r--r--ACE/apps/JAWS3/jaws3/Options.cpp25
-rw-r--r--ACE/apps/JAWS3/jaws3/Options.h40
-rw-r--r--ACE/apps/JAWS3/jaws3/Protocol_Handler.cpp65
-rw-r--r--ACE/apps/JAWS3/jaws3/Protocol_Handler.h80
-rw-r--r--ACE/apps/JAWS3/jaws3/Reactive_IO.cpp601
-rw-r--r--ACE/apps/JAWS3/jaws3/Reactive_IO.h72
-rw-r--r--ACE/apps/JAWS3/jaws3/Reactive_IO_Helpers.h308
-rw-r--r--ACE/apps/JAWS3/jaws3/Signal_Task.cpp83
-rw-r--r--ACE/apps/JAWS3/jaws3/Signal_Task.h32
-rw-r--r--ACE/apps/JAWS3/jaws3/Symbol_Table.cpp12
-rw-r--r--ACE/apps/JAWS3/jaws3/Symbol_Table.h53
-rw-r--r--ACE/apps/JAWS3/jaws3/Synch_IO.cpp265
-rw-r--r--ACE/apps/JAWS3/jaws3/Synch_IO.h65
-rw-r--r--ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.cpp130
-rw-r--r--ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.h37
-rw-r--r--ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.cpp80
-rw-r--r--ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.h32
-rw-r--r--ACE/apps/JAWS3/jaws3/TPR_Concurrency.cpp89
-rw-r--r--ACE/apps/JAWS3/jaws3/TPR_Concurrency.h35
-rw-r--r--ACE/apps/JAWS3/jaws3/Task_Timer.cpp106
-rw-r--r--ACE/apps/JAWS3/jaws3/Task_Timer.h56
-rw-r--r--ACE/apps/JAWS3/jaws3/Templates.cpp72
-rw-r--r--ACE/apps/JAWS3/jaws3/Timer.cpp53
-rw-r--r--ACE/apps/JAWS3/jaws3/Timer.h94
-rw-r--r--ACE/apps/JAWS3/jaws3/Timer_Helpers.cpp40
-rw-r--r--ACE/apps/JAWS3/jaws3/Timer_Helpers.h44
-rw-r--r--ACE/apps/JAWS3/jaws3/jaws.conf15
-rw-r--r--ACE/apps/JAWS3/jaws3/jaws3.mpc94
-rw-r--r--ACE/apps/JAWS3/jaws3/main.cpp33
53 files changed, 5159 insertions, 0 deletions
diff --git a/ACE/apps/JAWS3/jaws3/Asynch_IO.cpp b/ACE/apps/JAWS3/jaws3/Asynch_IO.cpp
new file mode 100644
index 00000000000..54b4f1c012d
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Asynch_IO.cpp
@@ -0,0 +1,308 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif /*JAWS_BUILD_DLL*/
+
+#include "ace/config-lite.h"
+
+#include "jaws3/IO.h"
+#include "jaws3/Asynch_IO.h"
+#include "jaws3/Event_Completer.h"
+#include "jaws3/Event_Result.h"
+
+#if defined (ACE_HAS_AIO_CALLS) || defined (ACE_HAS_WIN32_OVERLAPPED_IO)
+
+#include "jaws3/Asynch_IO_Helpers.h"
+
+void
+JAWS_Asynch_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ JAWS_EC_AH_Adapter *jecaha;
+ jecaha = JAWS_EC_AH_Adapter::make (completer);
+
+ ACE_Asynch_Write_Stream asynch_write_stream;
+
+ if (jecaha == 0
+ || asynch_write_stream.open (*jecaha, handle) == -1
+ || asynch_write_stream.write (*mb, mb->length (), act) == -1)
+ {
+ delete jecaha;
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_FAIL
+ );
+
+ if (completer)
+ completer->output_complete (io_result, act);
+ }
+}
+
+
+void
+JAWS_Asynch_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ JAWS_EC_AH_Adapter *jecaha;
+ jecaha = JAWS_EC_AH_Adapter::make (completer);
+
+ ACE_Asynch_Read_Stream asynch_read_stream;
+
+ if (jecaha == 0
+ || asynch_read_stream.open (*jecaha, handle) == -1
+ || asynch_read_stream.read (*mb, mb->space (), act) == -1)
+ {
+ delete jecaha;
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_RECV_FAIL
+ );
+
+ if (completer)
+ completer->output_complete (io_result, act);
+ }
+}
+
+
+void
+JAWS_Asynch_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ JAWS_EC_AH_Adapter *jecaha;
+ jecaha = JAWS_EC_AH_Adapter::make (completer);
+
+ ACE_Asynch_Transmit_File::Header_And_Trailer *header_and_trailer = 0;
+ header_and_trailer =
+ new ACE_Asynch_Transmit_File::Header_And_Trailer ( header
+ , header->length ()
+ , trailer
+ , trailer->length ()
+ );
+
+ ACE_Asynch_Transmit_File asynch_transmit_file;
+
+ if (source == ACE_INVALID_HANDLE
+ || jecaha == 0
+ || header_and_trailer == 0
+ || asynch_transmit_file.open (*jecaha, handle) == -1
+ || asynch_transmit_file.transmit_file ( source
+ , header_and_trailer
+ , 0
+ , 0
+ , 0
+ , 0
+ , 0
+ , act
+ ) == -1)
+ {
+ delete jecaha;
+ delete header_and_trailer;
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_FAIL
+ );
+
+ if (completer)
+ completer->output_complete (io_result, act);
+ }
+}
+
+
+
+JAWS_EC_AH_Adapter *
+JAWS_EC_AH_Adapter::make (JAWS_Event_Completer *completer)
+{
+ return new JAWS_EC_AH_Adapter (completer);
+}
+
+void
+JAWS_EC_AH_Adapter
+::handle_read_stream (const ACE_Asynch_Read_Stream::Result &result)
+{
+ JAWS_Event_Result io_result;
+
+ io_result = this->make_io_result ( result
+ , JAWS_Event_Result::JE_RECV_OK
+ , JAWS_Event_Result::JE_RECV_FAIL
+ );
+ // More useful diagnostics not implemented yet.
+
+ void *act = const_cast<void *> (result.act ());
+
+ this->completer_->input_complete (io_result, act);
+ delete this;
+}
+
+void
+JAWS_EC_AH_Adapter
+::handle_write_stream (const ACE_Asynch_Write_Stream::Result &result)
+{
+ JAWS_Event_Result io_result;
+
+ io_result = this->make_io_result ( result
+ , JAWS_Event_Result::JE_SEND_OK
+ , JAWS_Event_Result::JE_SEND_FAIL
+ );
+ // More useful diagnostics not implemented yet.
+
+ void *act = const_cast<void *> (result.act ());
+
+ this->completer_->output_complete (io_result, act);
+ delete this;
+}
+
+void
+JAWS_EC_AH_Adapter
+::handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result)
+{
+ JAWS_Event_Result io_result;
+
+ io_result = this->make_io_result ( result
+ , JAWS_Event_Result::JE_TRANSMIT_OK
+ , JAWS_Event_Result::JE_TRANSMIT_FAIL
+ );
+ // More useful diagnostics not implemented yet.
+ // Watch out for files not opened in overlapped IO mode.
+
+ void *act = const_cast<void *> (result.act ());
+
+ this->completer_->output_complete (io_result, act);
+ delete this;
+}
+
+JAWS_Event_Result
+JAWS_EC_AH_Adapter
+::make_io_result ( const ACE_Asynch_Result &result
+ , JAWS_Event_Result::JE_REASON reason_ok
+ , JAWS_Event_Result::JE_REASON reason_fail
+ )
+{
+ size_t bytes = result.bytes_transferred ();
+
+ JAWS_Event_Result::JE_STATUS status;
+ JAWS_Event_Result::JE_REASON reason;
+
+ if (result.success ())
+ {
+ status = JAWS_Event_Result::JE_OK;
+ reason = reason_ok;
+ }
+ else
+ {
+ status = JAWS_Event_Result::JE_ERROR;
+ reason = reason_fail;
+ }
+
+ JAWS_Event_Result io_result (bytes, status, reason);
+
+ return io_result;
+}
+
+#else /* EMULATE AIO WITH REACTOR */
+
+#include "jaws3/Reactive_IO.h"
+
+void
+JAWS_Asynch_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ JAWS_Reactive_IO::instance ()->send (handle, mb, completer, act);
+}
+
+
+void
+JAWS_Asynch_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ JAWS_Reactive_IO::instance ()->recv (handle, mb, completer, act);
+}
+
+
+void
+JAWS_Asynch_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ JAWS_Reactive_IO::instance ()->transmit ( handle
+ , source
+ , completer
+ , act
+ , header
+ , trailer
+ );
+}
+
+#endif /* ACE_HAS_AIO_CALLS || ACE_HAS_WIN32_OVERLAPPED_IO */
+
+// For now, we will simulate timed Asynch IO with timed Reactive IO.
+// In the future, we will implement the timed Asynch IO with timers
+// and Asynch IO cancelation.
+
+#include "jaws3/Reactive_IO.h"
+
+void
+JAWS_Asynch_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+ JAWS_Reactive_IO::instance ()->send (handle, mb, completer, tv, act);
+}
+
+
+void
+JAWS_Asynch_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+ JAWS_Reactive_IO::instance ()->recv (handle, mb, completer, tv, act);
+}
+
+
+void
+JAWS_Asynch_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ JAWS_Reactive_IO::instance ()->transmit ( handle
+ , source
+ , completer
+ , tv
+ , act
+ , header
+ , trailer
+ );
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Asynch_IO.h b/ACE/apps/JAWS3/jaws3/Asynch_IO.h
new file mode 100644
index 00000000000..68fd257cb24
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Asynch_IO.h
@@ -0,0 +1,72 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_ASYNCH_IO_H
+#define JAWS_ASYNCH_IO_H
+
+#include "ace/Asynch_IO.h"
+#include "ace/Message_Block.h"
+#include "ace/Singleton.h"
+#include "ace/Time_Value.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/IO.h"
+#include "jaws3/Event_Result.h"
+
+class JAWS_Asynch_IO;
+
+class JAWS_Export JAWS_Asynch_IO : public JAWS_IO_Impl
+{
+public:
+
+ static JAWS_Asynch_IO * instance (void)
+ {
+ return ACE_Singleton<JAWS_Asynch_IO, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+};
+
+#endif /* JAWS_ASYNCH_IO_H */
diff --git a/ACE/apps/JAWS3/jaws3/Asynch_IO_Helpers.h b/ACE/apps/JAWS3/jaws3/Asynch_IO_Helpers.h
new file mode 100644
index 00000000000..e82ab8189e5
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Asynch_IO_Helpers.h
@@ -0,0 +1,54 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_ASYNCH_IO_HELPERS_H
+#define JAWS_ASYNCH_IO_HELPERS_H
+
+#include "ace/Asynch_IO.h"
+#include "ace/Singleton.h"
+
+#include "jaws3/IO.h"
+#include "jaws3/Event_Result.h"
+#include "jaws3/Event_Completer.h"
+
+class JAWS_Asynch_IO;
+
+class JAWS_EC_AH_Adapter : public ACE_Handler
+// = TITLE
+// A JAWS_Event_Completer - ACE_Handler adapter.
+//
+// = DESCRIPTION
+// This class will be conditionally #included by jaws3/Asynch_IO.cpp
+// if the given platform supports POSIX or WIN32 asynch IO.
+{
+public:
+
+ static JAWS_EC_AH_Adapter * make (JAWS_Event_Completer *);
+
+ void handle_read_stream (const ACE_Asynch_Read_Stream::Result &result);
+
+ void handle_write_stream (const ACE_Asynch_Write_Stream::Result &result);
+
+ void handle_transmit_file (const ACE_Asynch_Transmit_File::Result &result);
+
+private:
+
+ JAWS_EC_AH_Adapter (JAWS_Event_Completer *completer)
+ : completer_ (completer)
+ {
+ }
+
+protected:
+
+ JAWS_Event_Result make_io_result ( const ACE_Asynch_Result &result
+ , JAWS_Event_Result::JE_REASON reason_ok
+ , JAWS_Event_Result::JE_REASON reason_fail
+ );
+
+private:
+
+ JAWS_Event_Completer *completer_;
+
+};
+
+#endif /* JAWS_ASYNCH_IO_HELPERS_H */
diff --git a/ACE/apps/JAWS3/jaws3/Cached_Allocator_T.cpp b/ACE/apps/JAWS3/jaws3/Cached_Allocator_T.cpp
new file mode 100644
index 00000000000..f2cb47c531a
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Cached_Allocator_T.cpp
@@ -0,0 +1,140 @@
+// $Id$
+
+#ifndef JAWS_CACHED_ALLOCATOR_T_CPP
+#define JAWS_CACHED_ALLOCATOR_T_CPP
+
+#include "jaws3/Cached_Allocator_T.h"
+
+template <class T, class ACE_LOCK> char *
+JAWS_Cached_Allocator<T, ACE_LOCK>::get_next_pool (char *pool)
+{
+ char *next = 0;
+ char *next_indirect = pool + (this->pool_size_);
+ ACE_OS::memcpy (&next, next_indirect, sizeof (char *));
+ return next;
+}
+
+template <class T, class ACE_LOCK> void
+JAWS_Cached_Allocator<T, ACE_LOCK>::set_next_pool (char *pool, char *next_pool)
+{
+ char *next_indirect = pool + (this->pool_size_);
+ ACE_OS::memcpy (next_indirect, &next_pool, sizeof (char *));
+}
+
+template <class T, class ACE_LOCK> void
+JAWS_Cached_Allocator<T, ACE_LOCK>::extend_pool (void)
+{
+ char *new_pool = 0;
+ ACE_NEW (new_pool, char[this->pool_size_ + sizeof (char *)]);
+
+ for (size_t c = 0; c < (this->pool_size_ / sizeof (T)); c++)
+ {
+ void* placement = new_pool + c * sizeof(T);
+ this->free_list_.add (new (placement) ACE_Cached_Mem_Pool_Node<T>);
+ this->set_next_pool (new_pool, 0);
+ }
+
+ if (this->pool_head_ == 0)
+ this->pool_head_ = this->pool_tail_ = new_pool;
+ else
+ this->set_next_pool (this->pool_tail_, new_pool);
+
+ this->pool_tail_ = new_pool;
+}
+
+template <class T, class ACE_LOCK>
+JAWS_Cached_Allocator<T, ACE_LOCK>::JAWS_Cached_Allocator (size_t n_chunks)
+ : pool_size_ (n_chunks * sizeof (T))
+ , pool_head_ (0)
+ , pool_tail_ (0)
+ , free_list_ (ACE_PURE_FREE_LIST)
+{
+ this->extend_pool ();
+}
+
+template <class T, class ACE_LOCK>
+JAWS_Cached_Allocator<T, ACE_LOCK>::~JAWS_Cached_Allocator (void)
+{
+ char *curr = this->pool_head_;
+
+ while (curr)
+ {
+ char *next = this->get_next_pool (curr);
+ delete [] curr;
+ curr = next;
+ }
+}
+
+template <class T, class ACE_LOCK> void *
+JAWS_Cached_Allocator<T, ACE_LOCK>::malloc (size_t nbytes)
+{
+ if (nbytes > sizeof (T))
+ return 0;
+
+ ACE_Cached_Mem_Pool_Node<T> *node = 0;
+ node = this->free_list_.remove ();
+
+ if (node == 0)
+ {
+ this->extend_pool ();
+ node = this->free_list_.remove ();
+ // ASSERT node != 0
+ }
+
+ // addr() call is really not absolutely necessary because of the way
+ // ACE_Cached_Mem_Pool_Node's internal structure arranged.
+ return node->addr ();
+}
+
+template <class T, class ACE_LOCK> void
+JAWS_Cached_Allocator<T, ACE_LOCK>::free (void *ptr)
+{
+ this->free_list_.add ((ACE_Cached_Mem_Pool_Node<T> *) ptr);
+}
+
+
+template <class T> JAWS_Cached_Allocator<T, ACE_SYNCH_NULL_MUTEX> *
+JAWS_TSS_Cached_Allocator<T>::ts_allocator (void)
+{
+ JAWS_Cached_Allocator<T, ACE_SYNCH_NULL_MUTEX> *ts_obj = 0;
+
+ ts_obj = this->ts_allocator_.ts_object ();
+
+ // Don't need double-check locking since this value is
+ // obtained from a thread specific context.
+ if (ts_obj == 0)
+ {
+ ACE_NEW_RETURN (ts_obj,
+ JAWS_CACHED_ALLOCATOR(T) (this->n_chunks_),
+ 0);
+ this->ts_allocator_.ts_object (ts_obj);
+ }
+
+ return ts_obj;
+}
+
+template <class T>
+JAWS_TSS_Cached_Allocator<T>::JAWS_TSS_Cached_Allocator (size_t n_chunks)
+ : n_chunks_ (n_chunks)
+{
+}
+
+template <class T>
+JAWS_TSS_Cached_Allocator<T>::~JAWS_TSS_Cached_Allocator (void)
+{
+}
+
+template <class T> void *
+JAWS_TSS_Cached_Allocator<T>::malloc (size_t nbytes)
+{
+ return this->ts_allocator ()->malloc (nbytes);
+}
+
+template <class T> void
+JAWS_TSS_Cached_Allocator<T>::free (void *ptr)
+{
+ this->ts_allocator ()->free (ptr);
+}
+
+
+#endif /* JAWS_CACHED_ALLOCATOR_T_CPP */
diff --git a/ACE/apps/JAWS3/jaws3/Cached_Allocator_T.h b/ACE/apps/JAWS3/jaws3/Cached_Allocator_T.h
new file mode 100644
index 00000000000..589d5710e47
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Cached_Allocator_T.h
@@ -0,0 +1,107 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_CACHED_ALLOCATOR_T_H
+#define JAWS_CACHED_ALLOCATOR_T_H
+
+#include "ace/ACE.h"
+#include "ace/Synch.h"
+#include "ace/Malloc.h"
+#include "ace/Free_List.h"
+
+#define JAWS_DEFAULT_ALLOCATOR_CHUNKS 10
+#define JAWS_CACHED_ALLOCATOR(T) \
+ JAWS_Cached_Allocator< T, ACE_SYNCH_NULL_MUTEX >
+
+template <class T, class ACE_LOCK>
+class JAWS_Cached_Allocator : public ACE_New_Allocator
+// = TITLE
+// Create a cached memory pool with <n_chunks> chunks each with
+// sizeof (<TYPE>) size.
+//
+// = DESCRIPTION
+// This class enables caching of dynamically allocated,
+// fixed-sized classes.
+{
+public:
+
+ JAWS_Cached_Allocator (size_t n_chunks = JAWS_DEFAULT_ALLOCATOR_CHUNKS);
+
+ ~JAWS_Cached_Allocator (void);
+
+ void* malloc (size_t);
+ // get a chunk of memory from free store.
+
+ void free (void *);
+ // return a chunk of memory back to free store.
+
+protected:
+
+ char * get_next_pool (char *pool);
+
+ void set_next_pool (char *pool, char *next_pool);
+
+ void extend_pool (void);
+
+private:
+
+ size_t pool_size_;
+
+ char *pool_head_;
+ // Head of memory pool.
+
+ char *pool_tail_;
+ // Tail of memory pool.
+
+ ACE_Locked_Free_List<ACE_Cached_Mem_Pool_Node<T>, ACE_LOCK> free_list_;
+ // Maintain a cached memory free list.
+
+};
+
+
+
+template <class T>
+class JAWS_TSS_Cached_Allocator : public ACE_New_Allocator
+// = TITLE
+// Create a thread specific cached memory pool with <n_chunks>
+// chunks each with sizeof (<TYPE>) size.
+//
+// = DESCRIPTION
+// This class enables caching of dynamically allocated,
+// fixed-sized classes.
+{
+public:
+
+ JAWS_TSS_Cached_Allocator (size_t n_chunks = JAWS_DEFAULT_ALLOCATOR_CHUNKS);
+
+ ~JAWS_TSS_Cached_Allocator (void);
+
+ void * malloc (size_t);
+ // get a chunk of memory from free store.
+
+ void free (void *);
+ // return a chunk of memory back to free store.
+
+protected:
+
+ JAWS_Cached_Allocator<T, ACE_SYNCH_NULL_MUTEX> * ts_allocator (void);
+
+private:
+
+ size_t n_chunks_;
+
+ ACE_TSS_TYPE (JAWS_CACHED_ALLOCATOR(T)) ts_allocator_;
+
+};
+
+
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "jaws3/Cached_Allocator_T.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("Cached_Allocator_T.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
+
+
+#endif /* JAWS_CACHED_ALLOCATOR_T_H */
diff --git a/ACE/apps/JAWS3/jaws3/Concurrency.cpp b/ACE/apps/JAWS3/jaws3/Concurrency.cpp
new file mode 100644
index 00000000000..3d42fde5fae
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Concurrency.cpp
@@ -0,0 +1,105 @@
+// $Id$
+
+#include "ace/OS_NS_strings.h"
+#include "ace/Message_Block.h"
+#include "ace/Singleton.h"
+#include "ace/Synch_Traits.h"
+#include "ace/Null_Mutex.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Concurrency.h"
+#include "jaws3/TPOOL_Concurrency.h"
+#include "jaws3/TPR_Concurrency.h"
+#include "jaws3/THYBRID_Concurrency.h"
+#include "jaws3/Options.h"
+
+
+typedef ACE_Singleton<ACE_Message_Block, ACE_SYNCH_NULL_MUTEX>
+ JAWS_Empty_Message_Block;
+
+
+int
+JAWS_Concurrency_Impl::svc (void)
+{
+ JAWS_Protocol_Handler *ph;
+
+ while (this->getq (ph) != -1)
+ {
+ if (ph == 0)
+ continue;
+
+ if (ph->service () == -1)
+ {
+ // TODO: Do I really want to call close here, or
+ // let the protocol handler close itself?
+ ph->dismiss ();
+ continue;
+ }
+ }
+
+ return 0;
+}
+
+
+JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
+::JAWS_Concurrency_Bridge (JAWS_Concurrency_Impl *impl)
+ : impl_ (impl)
+{
+ if (this->impl_ == 0)
+ {
+ const char *concurrency;
+ concurrency = JAWS_Options::instance ()->getenv ("JAWS_CONCURRENCY");
+ if (concurrency == 0)
+ concurrency = JAWS_DEFAULT_CONCURRENCY;
+
+ if (ACE_OS::strcasecmp (concurrency, "TPR") == 0)
+ this->impl_ = JAWS_TPR_Concurrency::instance ();
+ else if (ACE_OS::strcasecmp (concurrency, "TPOOL") == 0)
+ this->impl_ = JAWS_TPOOL_Concurrency::instance ();
+ else if (ACE_OS::strcasecmp (concurrency, "THYBRID") == 0)
+ this->impl_ = JAWS_THYBRID_Concurrency::instance ();
+ else
+ this->impl_ = JAWS_THYBRID_Concurrency::instance ();
+ // Since synchronous IO is the default IO, need an aggressive
+ // default concurrency mechanism.
+ }
+}
+
+
+int
+JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
+::putq (JAWS_Protocol_Handler *ph)
+{
+ return this->impl_->putq (ph);
+}
+
+
+int
+JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
+::getq (JAWS_Protocol_Handler *&ph)
+{
+ return this->impl_->getq (ph);
+}
+
+
+void
+JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>::shutdown (void)
+{
+ ACE_Message_Block *empty_mb = JAWS_Empty_Message_Block::instance ();
+ JAWS_CONCURRENCY_TASK *task;
+
+ task = JAWS_THYBRID_Concurrency::instance ();
+ task->putq (empty_mb);
+ task->wait ();
+
+ task = JAWS_TPOOL_Concurrency::instance ();
+ task->putq (empty_mb);
+ task->wait ();
+
+ task = JAWS_TPR_Concurrency::instance ();
+ task->putq (empty_mb);
+ task->wait ();
+}
diff --git a/ACE/apps/JAWS3/jaws3/Concurrency.h b/ACE/apps/JAWS3/jaws3/Concurrency.h
new file mode 100644
index 00000000000..2f8b8a18873
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Concurrency.h
@@ -0,0 +1,74 @@
+// -*- C++ -*-
+//
+// $Id$
+
+#ifndef JAWS_CONCURRENCY_H
+#define JAWS_CONCURRENCY_H
+
+#include "ace/Task.h"
+#include "ace/Singleton.h"
+#include "ace/Synch_Traits.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/Protocol_Handler.h"
+
+
+typedef ACE_Task<ACE_SYNCH> JAWS_CONCURRENCY_TASK;
+
+class JAWS_Export JAWS_Concurrency_Impl : public JAWS_CONCURRENCY_TASK
+{
+public:
+
+ virtual ~JAWS_Concurrency_Impl (void) {};
+
+ virtual int putq (JAWS_Protocol_Handler *ph) = 0;
+
+ virtual int getq (JAWS_Protocol_Handler *&ph) = 0;
+
+ int svc (void);
+
+};
+
+
+// Include the templates here.
+#include "jaws3/Concurrency_T.h"
+
+
+template<>
+class JAWS_Export JAWS_Concurrency_Bridge<JAWS_Concurrency_Impl>
+{
+public:
+
+ JAWS_Concurrency_Bridge (JAWS_Concurrency_Impl *impl = 0);
+
+ int putq (JAWS_Protocol_Handler *ph);
+ int getq (JAWS_Protocol_Handler *&ph);
+
+ void shutdown (void);
+
+protected:
+
+ JAWS_Concurrency_Impl *impl_;
+
+};
+
+
+#ifndef JAWS_CONCURRENCY_CONCRETE_IMPL
+#define JAWS_CONCURRENCY_CONCRETE_IMPL JAWS_Concurrency_Impl
+#endif /* JAWS_CONCURRENCY_CONCRETE_IMPL */
+
+
+class JAWS_Export JAWS_Concurrency
+ : public JAWS_Concurrency_Bridge<JAWS_CONCURRENCY_CONCRETE_IMPL>
+{
+public:
+
+ static JAWS_Concurrency * instance (void)
+ {
+ return ACE_Singleton<JAWS_Concurrency, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+};
+
+
+#endif /* JAWS_CONCURRENCY_H */
diff --git a/ACE/apps/JAWS3/jaws3/Concurrency_T.cpp b/ACE/apps/JAWS3/jaws3/Concurrency_T.cpp
new file mode 100644
index 00000000000..ea86da1c989
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Concurrency_T.cpp
@@ -0,0 +1,47 @@
+// $Id$
+
+#include "ace/Message_Block.h"
+#include "ace/Singleton.h"
+#include "ace/Synch_Traits.h"
+#include "ace/Null_Mutex.h"
+
+#include "jaws3/Concurrency_T.h"
+
+typedef ACE_Singleton<ACE_Message_Block, ACE_SYNCH_NULL_MUTEX>
+ JAWS_Empty_Message_Block;
+
+
+template <class CONCURRENCY_IMPL>
+JAWS_Concurrency_Bridge<CONCURRENCY_IMPL>
+::JAWS_Concurrency_Bridge (CONCURRENCY_IMPL *impl)
+ : impl_ (impl)
+{
+ if (this->impl_ == 0)
+ this->impl_ = CONCURRENCY_IMPL::instance ();
+}
+
+
+template <class CONCURRENCY_IMPL> int
+JAWS_Concurrency_Bridge<CONCURRENCY_IMPL>::putq (JAWS_Protocol_Handler *ph)
+{
+ return this->impl_->putq (ph);
+}
+
+
+template <class CONCURRENCY_IMPL> int
+JAWS_Concurrency_Bridge<CONCURRENCY_IMPL>::getq (JAWS_Protocol_Handler *&ph)
+{
+ return this->impl_->getq (ph);
+}
+
+
+template <class CONCURRENCY_IMPL> void
+JAWS_Concurrency_Bridge<CONCURRENCY_IMPL>::shutdown (void)
+{
+ ACE_Message_Block *empty_mb = JAWS_Empty_Message_Block::instance ();
+ JAWS_CONCURRENCY_TASK *task;
+
+ task = this->impl_;
+ task->putq (empty_mb);
+ task->wait ();
+}
diff --git a/ACE/apps/JAWS3/jaws3/Concurrency_T.h b/ACE/apps/JAWS3/jaws3/Concurrency_T.h
new file mode 100644
index 00000000000..704da56faea
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Concurrency_T.h
@@ -0,0 +1,50 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_CONCURRENCY_T_H
+#define JAWS_CONCURRENCY_T_H
+
+// This gets me the ACE template defines without having to #include "ace/OS.h".
+#include "ace/config-lite.h"
+
+class JAWS_Protocol_Handler;
+
+template <class CONCURRENCY_IMPL>
+class JAWS_Concurrency_Bridge
+// = TITLE
+// The Concurrency Bridge uses the Concrete Bridge pattern.
+//
+// = DESCRIPTION
+// The Concurrency Bridge class plays the role of Abstraction
+// in the Bridge pattern. If the CONCURRENCY_IMPL is the
+// base class JAWS_Concurrency_Impl, then it plays the classic
+// role. If the CONCURRENCY_IMPL is one of the Concrete
+// Implementors, then its role is more that of an Adapter,
+// which is like Bridge, but without the polymorphism overhead.
+//
+{
+public:
+
+ JAWS_Concurrency_Bridge (CONCURRENCY_IMPL *impl = 0);
+
+ int putq (JAWS_Protocol_Handler *ph);
+ int getq (JAWS_Protocol_Handler *&ph);
+
+ void shutdown (void);
+
+protected:
+
+ CONCURRENCY_IMPL *impl_;
+
+};
+
+#if defined (ACE_TEMPLATES_REQUIRE_SOURCE)
+#include "jaws3/Concurrency_T.cpp"
+#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */
+
+#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA)
+#pragma implementation ("Concurrency_T.cpp")
+#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */
+
+
+#endif /* JAWS_CONCURRENCY_T_H */
diff --git a/ACE/apps/JAWS3/jaws3/Config_File.cpp b/ACE/apps/JAWS3/jaws3/Config_File.cpp
new file mode 100644
index 00000000000..cf8ab94d3a4
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Config_File.cpp
@@ -0,0 +1,304 @@
+// $Id$
+
+#include "ace/OS_NS_stdlib.h"
+#include "ace/OS_NS_string.h"
+#include "ace/FILE_Connector.h"
+#include "ace/Message_Block.h"
+#include "ace/Singleton.h"
+#include "ace/Unbounded_Queue.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Config_File.h"
+#include "jaws3/Symbol_Table.h"
+
+// = Helper class to manage "constant" strings.
+
+class JAWS_strings
+{
+public:
+
+ ~JAWS_strings (void)
+ {
+ void *p;
+ while (this->queue_.dequeue_head (p) != -1)
+ ACE_OS::free (p);
+ }
+
+ const ACE_TCHAR * duplicate (const ACE_TCHAR *s)
+ {
+ void **x;
+ const ACE_TCHAR *d = 0;
+ ACE_Unbounded_Queue_Iterator<void *> iter (this->queue_);
+
+ while (iter.next (x))
+ {
+ d = (const ACE_TCHAR *) *x;
+ if (ACE_OS::strcmp (d, s) == 0)
+ break;
+ d = 0;
+ iter.advance ();
+ }
+
+ if (d == 0)
+ {
+ d = ACE_OS::strdup (s);
+ this->queue_.enqueue_tail ((void *) d);
+ }
+
+ return d;
+ }
+
+private:
+
+ ACE_Unbounded_Queue<void *> queue_;
+
+};
+
+
+// = Underlying implementation class.
+
+
+class JAWS_Config_File_Impl
+{
+public:
+
+ JAWS_Config_File_Impl (const ACE_TCHAR *config_file);
+ ~JAWS_Config_File_Impl (void);
+ int find (const ACE_TCHAR *key, const ACE_TCHAR *&value);
+
+ void parse_file (void);
+ void reset (void);
+ void dump (void);
+
+ enum { JAWS_CONFIG_FILE_SYMBOL_TABLE_SIZE = 211 };
+
+private:
+
+ ACE_FILE_Addr faddr_;
+ JAWS_strings *strings_;
+ JAWS_Symbol_Table *symbols_;
+
+};
+
+JAWS_Config_File_Impl::JAWS_Config_File_Impl (const ACE_TCHAR *config_file)
+ : faddr_ (config_file)
+ , strings_ (0)
+ , symbols_ (0)
+{
+ this->strings_ = new JAWS_strings;
+ this->symbols_ = new JAWS_Symbol_Table (JAWS_CONFIG_FILE_SYMBOL_TABLE_SIZE);
+ this->parse_file ();
+}
+
+JAWS_Config_File_Impl::~JAWS_Config_File_Impl (void)
+{
+ delete this->symbols_;
+ this->symbols_ = 0;
+ delete this->strings_;
+ this->strings_ = 0;
+}
+
+int
+JAWS_Config_File_Impl::find (const ACE_TCHAR *key, const ACE_TCHAR *&value)
+{
+ return this->symbols_->find (key, value);
+}
+
+void
+JAWS_Config_File_Impl::parse_file (void)
+{
+ ACE_FILE_Connector fconnector;
+ ACE_FILE_IO fio;
+
+ if (fconnector.connect ( fio
+ , this->faddr_
+ , 0
+ , ACE_Addr::sap_any
+ , 0
+ , O_RDONLY
+ ) == -1)
+ return;
+
+ ACE_Message_Block buffer (8192);
+ ACE_Message_Block line (4096);
+ ssize_t count = 0;
+ const ACE_TCHAR *sym_name;
+ const ACE_TCHAR *sym_value;
+ int last_line_was_read = 0;
+ ACE_TCHAR *end_of_current_line = 0;
+ ACE_TCHAR *p = 0;
+
+ while (last_line_was_read
+ || (count = fio.recv (buffer.wr_ptr (), buffer.space () - 2)) >= 0)
+ {
+ end_of_current_line = 0;
+
+ // Make sure input is newline terminated if it is the last line,
+ // and always null terminated.
+ if (! last_line_was_read)
+ {
+ if (count > 0)
+ {
+ buffer.wr_ptr (count);
+ // Scan forward for at least one newline character
+ p = buffer.rd_ptr ();
+ while (p != buffer.wr_ptr ())
+ {
+ if (*p == '\n')
+ break;
+ p++;
+ }
+
+ if (p == buffer.wr_ptr ())
+ continue;
+
+ end_of_current_line = p;
+ }
+ else
+ {
+ if (buffer.wr_ptr ()[-1] != '\n')
+ {
+ buffer.wr_ptr ()[0] = '\n';
+ buffer.wr_ptr (1);
+ }
+
+ last_line_was_read = 1;
+ }
+
+ buffer.wr_ptr ()[0] = '\0';
+ }
+
+ if (end_of_current_line == 0)
+ {
+ end_of_current_line = buffer.rd_ptr ();
+ while (*end_of_current_line != '\n')
+ end_of_current_line++;
+ }
+
+ // If buffer is not pointing to a continuation line, or there is
+ // no more input, then can commit the scanned configuration
+ // line.
+ if (line.length () != 0
+ && ((last_line_was_read && buffer.length () == 0)
+ || (buffer.rd_ptr ()[0] != ' '
+ && buffer.rd_ptr ()[0] != '\t')))
+ {
+ ACE_TCHAR *name = 0;
+ ACE_TCHAR *value = 0;
+
+ name = line.rd_ptr ();
+ for (p = name; *p != '\0'; p++)
+ {
+ if (*p == '=')
+ {
+ line.rd_ptr (p+1);
+ while (p != name && (p[-1] == ' ' || p[-1] == '\t'))
+ p--;
+ *p = '\0';
+ }
+ }
+
+ if (*name)
+ {
+ value = line.rd_ptr ();
+ while (*value == ' ' || *value == '\t')
+ value++;
+ p = line.wr_ptr ();
+ while (p != value && (p[-1] == ' ' || p[-1] == '\t'))
+ p--;
+ *p = '\0';
+
+ sym_name = this->strings_->duplicate (name);
+ sym_value = this->strings_->duplicate (value);
+ this->symbols_->rebind (sym_name, sym_value);
+ }
+
+ line.reset ();
+ }
+
+ // If we are done, we are done!
+ if (last_line_was_read && buffer.length () == 0)
+ break;
+
+ // If the buffer is pointing at a comment line, ignore it.
+ if (buffer.rd_ptr ()[0] == '#'
+ || buffer.rd_ptr ()[0] == '\n'
+ || (buffer.rd_ptr ()[0] == '\r' && buffer.rd_ptr ()[1] == '\n'))
+ {
+ buffer.rd_ptr (end_of_current_line + 1);
+ buffer.crunch ();
+ continue;
+ }
+
+ // Whatever is left is either the start of a name-value-pair or a
+ // continuation of one.
+ line.copy (buffer.rd_ptr (),
+ end_of_current_line - buffer.rd_ptr ());
+ p = line.wr_ptr ();
+ while (p != line.rd_ptr () && (p[-1] == ' ' || p[-1] == '\t'))
+ p--;
+ line.wr_ptr (p);
+ line.wr_ptr ()[0] = '\0';
+ buffer.rd_ptr (end_of_current_line + 1);
+ buffer.crunch ();
+ }
+
+ fio.close ();
+}
+
+void
+JAWS_Config_File_Impl::reset (void)
+{
+ delete this->symbols_;
+ delete this->strings_;
+ this->strings_ = new JAWS_strings;
+ this->symbols_ = new JAWS_Symbol_Table (JAWS_CONFIG_FILE_SYMBOL_TABLE_SIZE);
+ this->parse_file ();
+}
+
+void
+JAWS_Config_File_Impl::dump (void)
+{
+ JAWS_SYMBOL_TABLE_ITERATOR iter (*this->symbols_);
+ JAWS_SYMBOL_TABLE_ENTRY *entry = 0;
+
+ while (iter.next (entry))
+ {
+ ACE_DEBUG ((LM_DEBUG, "[%D|%t] %s=%s\n",
+ entry->ext_id_,
+ entry->int_id_));
+ iter.advance ();
+ }
+}
+
+JAWS_Config_File::JAWS_Config_File (const ACE_TCHAR *config_file,
+ const ACE_TCHAR *config_dir)
+{
+ ACE_TCHAR filename[MAXPATHLEN];
+ ACE_OS::strcpy (filename, config_dir);
+ ACE_OS::strcat (filename, config_file);
+
+ this->impl_ = new JAWS_Config_File_Impl (filename);
+}
+
+int
+JAWS_Config_File::find (const ACE_TCHAR *key, const ACE_TCHAR *&value)
+{
+ return this->impl_->find (key, value);
+}
+
+void
+JAWS_Config_File::reset (void)
+{
+ this->impl_->reset ();
+}
+
+void
+JAWS_Config_File::dump (void)
+{
+ this->impl_->dump ();
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Config_File.h b/ACE/apps/JAWS3/jaws3/Config_File.h
new file mode 100644
index 00000000000..aab87c502ca
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Config_File.h
@@ -0,0 +1,73 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_CONFIG_FILE_H
+#define JAWS_CONFIG_FILE_H
+
+#include "jaws3/Export.h"
+
+class JAWS_Config_File;
+class JAWS_Config_File_Impl;
+
+class JAWS_Export JAWS_Config_File
+// = TITLE
+// A simple configuration file manager.
+//
+// = DESCRIPTION
+// Reads in a configuration file. The syntax of the configuration
+// file is:
+// = BEGIN<CODE>
+// <configuration-file> := <configuration-seq>
+//
+// <configuration-seq> := <configuration-line> [<configuration-seq>]
+//
+// <configuration-line> := <name-value-pair-line>
+// | <comment-line>
+//
+// <name-value-pair-line> := <name> '=' <value-line>
+//
+// <name> := <char-seq>
+//
+// <value-line> := [<char-seq>] <LF> [<continuation-seq>]
+//
+// <continuation-seq> := <continuation-line> [<continuation-seq>]
+//
+// <continuation-line> := <LWSP> [<char-seq>] <LF>
+//
+// <comment-line> := [<comment>] <LF>
+//
+// <comment> := '#' <char-seq>
+//
+// <char-seq> := <char> [<char-seq>]
+// = END<CODE>
+// No <configuration-line> is to exceed 4094 characters.
+{
+public:
+
+ // = Initialization
+
+ JAWS_Config_File (const ACE_TCHAR *config_file,
+ const ACE_TCHAR *config_dir = "./");
+ // Parse the specified <config_file> in the <config_dir>.
+
+ // = Searching
+
+ int find (const ACE_TCHAR *key, const ACE_TCHAR *&value);
+ // Find the <value> associated with <key>.
+
+public:
+
+ void reset (void);
+ // Re-read the configuration file.
+
+ void dump (void);
+ // Dump the values of all configuration variables.
+
+private:
+
+ JAWS_Config_File_Impl *impl_;
+ // Opaque implementation.
+
+};
+
+#endif /* JAWS_CONFIG_FILE_H */
diff --git a/ACE/apps/JAWS3/jaws3/Datagram.cpp b/ACE/apps/JAWS3/jaws3/Datagram.cpp
new file mode 100644
index 00000000000..3849e7afd1d
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Datagram.cpp
@@ -0,0 +1,86 @@
+// $Id$
+
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif /*JAWS_BUILD_DLL*/
+
+#include "jaws3/Datagram.h"
+
+
+JAWS_Datagram::JAWS_Datagram (JAWS_Datagram_Impl *impl)
+ : impl_ (impl)
+{
+}
+
+void
+JAWS_Datagram::accept ( const ACE_Addr &local_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->accept (local_sap, new_dgram, completer, act);
+}
+
+void
+JAWS_Datagram::connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->connect (remote_sap, new_dgram, completer, act);
+}
+
+void
+JAWS_Datagram::connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , const ACE_Addr &local_sap
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->connect (remote_sap, new_dgram, local_sap, completer, act);
+}
+
+void
+JAWS_Datagram::accept ( const ACE_Addr &local_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act
+ )
+{
+ this->impl_->accept (local_sap, new_dgram, completer, timeout, act);
+}
+
+void
+JAWS_Datagram::connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act
+ )
+{
+ this->impl_->connect (remote_sap, new_dgram, completer, timeout, act);
+}
+
+void
+JAWS_Datagram::connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , const ACE_Addr &local_sap
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act
+ )
+{
+ this->impl_->connect ( remote_sap
+ , new_dgram
+ , local_sap
+ , completer
+ , timeout
+ , act
+ );
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Datagram.h b/ACE/apps/JAWS3/jaws3/Datagram.h
new file mode 100644
index 00000000000..370088892de
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Datagram.h
@@ -0,0 +1,139 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_DATAGRAM_H
+#define JAWS_DATAGRAM_H
+
+#include "ace/Addr.h"
+#include "ace/Synch.h"
+#include "ace/Singleton.h"
+#include "ace/SOCK_Dgram.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/Event_Completer.h"
+
+class JAWS_Export JAWS_Datagram_Impl
+{
+public:
+
+ virtual ~JAWS_Datagram_Impl (void) {}
+
+ virtual void accept ( const ACE_Addr &local_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+ // The address to new_dgram is passed back as the data member of
+ // the JAWS_Event_Result that is returned to the completer.
+
+ virtual void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+ // The address to new_dgram is passed back as the data member of
+ // the JAWS_Event_Result that is returned to the completer.
+ // ADDR_ANY is assumed for the local access point.
+
+ virtual void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , const ACE_Addr &local_sap
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+ // The address to new_dgram is passed back as the data member of
+ // the JAWS_Event_Result that is returned to the completer.
+ // Use the specified local access point.
+
+ virtual void accept ( const ACE_Addr &local_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act = 0
+ ) = 0;
+ // The address to new_dgram is passed back as the data member of
+ // the JAWS_Event_Result that is returned to the completer.
+
+ virtual void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act = 0
+ ) = 0;
+ // The address to new_dgram is passed back as the data member of
+ // the JAWS_Event_Result that is returned to the completer.
+ // ADDR_ANY is assumed for the local access point.
+
+ virtual void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , const ACE_Addr &local_sap
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act = 0
+ ) = 0;
+ // The address to new_dgram is passed back as the data member of
+ // the JAWS_Event_Result that is returned to the completer.
+ // Use the specified local access point.
+
+};
+
+
+class JAWS_Export JAWS_Datagram
+{
+public:
+
+ JAWS_Datagram (JAWS_Datagram_Impl *impl = 0);
+
+ static JAWS_Datagram * instance (void)
+ {
+ return ACE_Singleton<JAWS_Datagram, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ void accept ( const ACE_Addr &local_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , const ACE_Addr &local_sap
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void accept ( const ACE_Addr &local_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act = 0
+ );
+
+ void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act = 0
+ );
+
+ void connect ( const ACE_Addr &remote_sap
+ , ACE_SOCK_Dgram &new_dgram
+ , const ACE_Addr &local_sap
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &timeout
+ , void *act = 0
+ );
+
+private:
+
+ JAWS_Datagram_Impl *impl_;
+
+};
+
+#endif /* JAWS_DATAGRAM_H */
diff --git a/ACE/apps/JAWS3/jaws3/Event_Completer.cpp b/ACE/apps/JAWS3/jaws3/Event_Completer.cpp
new file mode 100644
index 00000000000..70df04e90fc
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Event_Completer.cpp
@@ -0,0 +1,55 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Event_Completer.h"
+
+// Default do nothing completers.
+
+JAWS_Event_Completer::~JAWS_Event_Completer (void)
+{
+}
+
+void
+JAWS_Event_Completer::default_complete (const JAWS_Event_Result &, void *)
+{
+}
+
+void
+JAWS_Event_Completer::accept_complete (const JAWS_Event_Result &r, void *d)
+{
+ this->default_complete (r, d);
+}
+
+void
+JAWS_Event_Completer::connect_complete (const JAWS_Event_Result &r, void *d)
+{
+ this->default_complete (r, d);
+}
+
+void
+JAWS_Event_Completer::input_complete (const JAWS_Event_Result &r, void *d)
+{
+ this->default_complete (r, d);
+}
+
+void
+JAWS_Event_Completer::output_complete (const JAWS_Event_Result &r, void *d)
+{
+ this->default_complete (r, d);
+}
+
+void
+JAWS_Event_Completer::timer_complete (const JAWS_Event_Result &r, void *d)
+{
+ this->default_complete (r, d);
+}
+
+void
+JAWS_Event_Completer::lambda_complete (const JAWS_Event_Result &r, void *d)
+{
+ this->default_complete (r, d);
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Event_Completer.h b/ACE/apps/JAWS3/jaws3/Event_Completer.h
new file mode 100644
index 00000000000..6114605437d
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Event_Completer.h
@@ -0,0 +1,43 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_EVENT_COMPLETER_H
+#define JAWS_EVENT_COMPLETER_H
+
+#include "jaws3/Export.h"
+#include "jaws3/Event_Result.h"
+
+class JAWS_Event_Completer;
+
+class JAWS_Export JAWS_Event_Completer
+// = TITLE
+// Event completion callback class.
+{
+public:
+
+ virtual ~JAWS_Event_Completer (void);
+
+ virtual void accept_complete (const JAWS_Event_Result &r, void *act = 0);
+ // The callback entry point when input has been read.
+
+ virtual void connect_complete (const JAWS_Event_Result &r, void *act = 0);
+ // The callback entry point when input has been read.
+
+ virtual void input_complete (const JAWS_Event_Result &r, void *act = 0);
+ // The callback entry point when input has been read.
+
+ virtual void output_complete (const JAWS_Event_Result &r, void *act = 0);
+ // The callback entry point when output has been completely written.
+
+ virtual void timer_complete (const JAWS_Event_Result &r, void *act = 0);
+ // The callback entry point when timer has expired.
+
+ virtual void lambda_complete (const JAWS_Event_Result &r, void *act = 0);
+ // The callback entry point when a lambda event completes.
+
+ virtual void default_complete (const JAWS_Event_Result &r, void *act = 0);
+ // The defaul callback entry point when an event completes.
+
+};
+
+#endif /* JAWS_EVENT_COMPLETER_H */
diff --git a/ACE/apps/JAWS3/jaws3/Event_Dispatcher.cpp b/ACE/apps/JAWS3/jaws3/Event_Dispatcher.cpp
new file mode 100644
index 00000000000..6b498e23125
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Event_Dispatcher.cpp
@@ -0,0 +1,52 @@
+// $Id$
+
+#include "ace/Log_Msg.h"
+#include "ace/Thread.h"
+#include "ace/Reactor.h"
+#include "ace/Proactor.h"
+#include "ace/POSIX_Proactor.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif /*JAWS_BUILD_DLL*/
+
+#include "jaws3/Event_Dispatcher.h"
+
+static ACE_THR_FUNC_RETURN
+JAWS_Event_Dispatcher_Proactor_Event_Loop (void *)
+{
+ ACE_Proactor::run_event_loop ();
+ return 0;
+}
+
+
+void
+JAWS_Event_Dispatcher::end_event_loop (void)
+{
+ ACE_Reactor::end_event_loop ();
+}
+
+
+void
+JAWS_Event_Dispatcher::run_event_loop (void)
+{
+ // First, initiate the proactor thread
+
+ int result;
+ result = ACE_Thread::spawn ( JAWS_Event_Dispatcher_Proactor_Event_Loop
+ , 0
+ , THR_BOUND
+ );
+ if (result < 0)
+ {
+ ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Thread::spawn"));
+ return;
+ }
+
+ // Now, enter the reactor's event loop.
+ ACE_Reactor::run_event_loop ();
+
+ // End the proactor's event loop if reactor was interrupted.
+ ACE_Proactor::end_event_loop ();
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Event_Dispatcher.h b/ACE/apps/JAWS3/jaws3/Event_Dispatcher.h
new file mode 100644
index 00000000000..30a29eed34f
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Event_Dispatcher.h
@@ -0,0 +1,52 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_EVENT_DISPATCHER_H
+#define JAWS_EVENT_DISPATCHER_H
+
+#include "ace/Reactor.h"
+#include "ace/Reactor_Token_T.h"
+#include "ace/Select_Reactor.h"
+
+#include "jaws3/Export.h"
+
+// We are using the Reactor in a single threaded manner,
+// so if we are using the Select Reactor, get rid of the
+// big reactor lock.
+
+typedef ACE_Reactor_Token_T<ACE_Noop_Token>
+ ACE_Select_Reactor_Noop_Token;
+
+typedef ACE_Select_Reactor_T<ACE_Select_Reactor_Noop_Token>
+ ACE_Select_NULL_LOCK_Reactor;
+
+#if !defined (ACE_WIN32) \
+ || !defined (ACE_HAS_WINSOCK2) || (ACE_HAS_WINSOCK2 == 0) \
+ || defined (ACE_USE_SELECT_REACTOR_FOR_REACTOR_IMPL) \
+ || defined (ACE_USE_TP_REACTOR_FOR_REACTOR_IMPL)
+
+#define ACE_REACTOR_INSTANCE_INIT \
+ do { \
+ ACE_Select_NULL_LOCK_Reactor *select_reactor; \
+ select_reactor = new ACE_Select_NULL_LOCK_Reactor; \
+ ACE_Reactor::instance (new ACE_Reactor (select_reactor, 1), 1); \
+ } while (0)
+
+#else
+
+#define ACE_REACTOR_INSTANCE_INIT ACE_Reactor::instance ()
+
+#endif /* ACE_WIN32 */
+
+class JAWS_Event_Dispatcher;
+
+class JAWS_Export JAWS_Event_Dispatcher
+{
+public:
+
+ static void end_event_loop (void);
+ static void run_event_loop (void);
+
+};
+
+#endif /* JAWS_EVENT_DISPATCHER_H */
diff --git a/ACE/apps/JAWS3/jaws3/Event_Result.h b/ACE/apps/JAWS3/jaws3/Event_Result.h
new file mode 100644
index 00000000000..c82bc12d408
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Event_Result.h
@@ -0,0 +1,104 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_EVENT_RESULT_H
+#define JAWS_EVENT_RESULT_H
+
+#include "ace/OS_NS_errno.h"
+#include "ace/os_include/os_stddef.h" /* Needed for size_t */
+
+#include "jaws3/Export.h"
+
+class JAWS_Event_Result;
+
+class JAWS_Export JAWS_Event_Result
+{
+public:
+
+ enum JE_STATUS
+ { JE_IDLE
+ , JE_OK
+ , JE_PENDING
+ , JE_CANCEL
+ , JE_ERROR
+ };
+
+ enum JE_REASON
+ { JE_NO_REASON
+ , JE_ACCEPT_OK
+ , JE_ACCEPT_PENDING
+ , JE_ACCEPT_TIMEOUT
+ , JE_ACCEPT_FAIL
+ , JE_CONNECT_OK
+ , JE_CONNECT_PENDING
+ , JE_CONNECT_TIMEOUT
+ , JE_CONNECT_FAIL
+ , JE_SEND_OK
+ , JE_SEND_PENDING
+ , JE_SEND_BLOCKED
+ , JE_SEND_SHORT
+ , JE_SEND_TIMEOUT
+ , JE_SEND_FAIL
+ , JE_RECV_OK
+ , JE_RECV_PENDING
+ , JE_RECV_BLOCKED
+ , JE_RECV_SHORT
+ , JE_RECV_TIMEOUT
+ , JE_RECV_FAIL
+ , JE_TRANSMIT_OK
+ , JE_TRANSMIT_PENDING
+ , JE_TRANSMIT_BLOCKED
+ , JE_TRANSMIT_SHORT
+ , JE_TRANSMIT_TIMEOUT
+ , JE_TRANSMIT_FAIL
+ , JE_TIMER_OK
+ , JE_TIMER_CANCEL
+ , JE_TIMER_PENDING
+ , JE_TIMER_FAIL
+ , JE_LAMBDA_OK
+ , JE_LAMBDA_CANCEL
+ , JE_LAMBDA_PENDING
+ , JE_LAMBDA_SHORT
+ , JE_LAMBDA_TIMEOUT
+ , JE_LAMBDA_FAIL
+ };
+
+ JAWS_Event_Result ( size_t bytes = 0
+ , JE_STATUS status = JE_IDLE
+ , JE_REASON reason = JE_NO_REASON
+ , int error_number = -1
+ , void * data = 0
+ )
+ : bytes_ (bytes)
+ , status_ (status)
+ , reason_ (reason)
+ , error_number_ (error_number)
+ , data_ (data)
+ {
+ if (this->error_number_ == -1)
+ this->error_number_ = errno;
+ }
+
+ size_t bytes (void) const { return this->bytes_; }
+
+ int status (void) const { return this->status_; }
+ int reason (void) const { return this->reason_; }
+
+ int error_number (void) const { return (errno = this->error_number_); }
+
+ void * data (void) const { return this->data_; }
+
+private:
+
+ size_t bytes_;
+
+ JE_STATUS status_;
+ JE_REASON reason_;
+
+ int error_number_;
+
+ void *data_;
+
+};
+
+#endif /* JAWS_EVENT_RESULT_H */
diff --git a/ACE/apps/JAWS3/jaws3/Export.h b/ACE/apps/JAWS3/jaws3/Export.h
new file mode 100644
index 00000000000..8af831df529
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Export.h
@@ -0,0 +1,48 @@
+// $Id$
+
+// Definition for Win32 Export directives.
+// This file is generated automatically by
+// ${TAO_ROOT}/TAO_IDL/GenExportH.BAT
+// ------------------------------
+#ifndef JAWS_EXPORT_H
+#define JAWS_EXPORT_H
+
+#include "ace/config-all.h"
+
+#if !defined (ACE_LACKS_PRAGMA_ONCE)
+# pragma once
+#endif /* ACE_LACKS_PRAGMA_ONCE */
+
+#if defined (ACE_AS_STATIC_LIBS)
+# if !defined (JAWS_HAS_DLL)
+# define JAWS_HAS_DLL 0
+# endif /* ! ACE_HAS_DLL */
+#else
+# if !defined (JAWS_HAS_DLL)
+# define JAWS_HAS_DLL 1
+# endif /* ! ACE_HAS_DLL */
+#endif /* ACE_AS_STATIC_LIB */
+
+#if defined (JAWS_HAS_DLL)
+# if (JAWS_HAS_DLL == 1)
+# if defined (JAWS_BUILD_DLL)
+# define JAWS_Export ACE_Proper_Export_Flag
+# define JAWS_SINGLETON_DECLARATION(T) \
+ ACE_EXPORT_SINGLETON_DECLARATION (T)
+# else
+# define JAWS_Export ACE_Proper_Import_Flag
+# define JAWS_SINGLETON_DECLARATION(T) \
+ ACE_IMPORT_SINGLETON_DECLARATION (T)
+# endif /* JAWS_BUILD_DLL */
+# else
+# define JAWS_Export
+# define JAWS_SINGLETON_DECLARATION(T)
+# endif /* ! JAWS_HAS_DLL == 1 */
+#else
+# define JAWS_Export
+# define JAWS_SINGLETON_DECLARATION(T)
+#endif /* JAWS_HAS_DLL */
+
+#endif /* JAWS_EXPORT_H */
+ // End of auto generated file.
+
diff --git a/ACE/apps/JAWS3/jaws3/FILE.cpp b/ACE/apps/JAWS3/jaws3/FILE.cpp
new file mode 100644
index 00000000000..ed4723962ea
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/FILE.cpp
@@ -0,0 +1,93 @@
+// $Id$
+
+#include "ace/config-all.h"
+#include "ace/Guard_T.h"
+#include "ace/Synch_Traits.h"
+#include "ace/Thread_Mutex.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/FILE.h"
+
+
+JAWS_FILE::JAWS_FILE (void)
+ : map_ (0)
+ , can_map_ (0)
+{
+}
+
+JAWS_FILE::~JAWS_FILE (void)
+{
+ delete this->map_;
+ this->map_ = 0;
+}
+
+ACE_Mem_Map *
+JAWS_FILE::mem_map (int length,
+ int prot,
+ int share,
+ void *addr,
+ ACE_OFF_T offset,
+ LPSECURITY_ATTRIBUTES sa) const
+{
+ if (this->can_map_ == 0)
+ return 0;
+
+ JAWS_FILE *mutable_this = (JAWS_FILE *) this;
+ return mutable_this->mem_map (length, prot, share, addr, offset, sa);
+}
+
+ACE_Mem_Map *
+JAWS_FILE::mem_map (int length,
+ int prot,
+ int share,
+ void *addr,
+ ACE_OFF_T offset,
+ LPSECURITY_ATTRIBUTES sa)
+{
+ if (this->can_map_ == 0)
+ return 0;
+
+ if (this->map_ == 0)
+ {
+ ACE_Guard<ACE_SYNCH_MUTEX> g (this->lock_);
+
+ if (this->map_ == 0)
+ {
+ this->map_ = new ACE_Mem_Map;
+ if (this->map_ != 0)
+ {
+ int r = this->map_->map (this->get_handle (),
+ static_cast<size_t> (length),
+ prot,
+ share,
+ addr,
+ offset,
+ sa);
+ if (r < 0)
+ {
+ delete this->map_;
+ this->map_ = 0;
+ }
+ }
+ }
+ }
+
+ return this->map_;
+
+}
+
+
+ACE_Mem_Map *
+JAWS_FILE::map (void) const
+{
+ return this->map_;
+}
+
+void
+JAWS_FILE::can_map (int flag)
+{
+ this->can_map_ = (flag != 0);
+}
diff --git a/ACE/apps/JAWS3/jaws3/FILE.h b/ACE/apps/JAWS3/jaws3/FILE.h
new file mode 100644
index 00000000000..be2bea9e291
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/FILE.h
@@ -0,0 +1,50 @@
+// -*- c++ -*-
+//
+// $Id$
+
+
+#ifndef JAWS_FILE_H
+#define JAWS_FILE_H
+
+#include "ace/FILE_IO.h"
+#include "ace/Mem_Map.h"
+
+#include "jaws3/Export.h"
+
+class JAWS_Export JAWS_FILE : public ACE_FILE_IO
+//
+// Like ACE_FILE_IO, but support for ACE_Mem_Map;
+{
+public:
+
+ JAWS_FILE (void);
+
+ ~JAWS_FILE (void);
+
+ ACE_Mem_Map *mem_map (int length = -1,
+ int prot = PROT_RDWR,
+ int share = ACE_MAP_PRIVATE,
+ void *addr = 0,
+ ACE_OFF_T offset = 0,
+ LPSECURITY_ATTRIBUTES sa = 0);
+ ACE_Mem_Map *mem_map (int length = -1,
+ int prot = PROT_RDWR,
+ int share = ACE_MAP_PRIVATE,
+ void *addr = 0,
+ ACE_OFF_T offset = 0,
+ LPSECURITY_ATTRIBUTES sa = 0) const;
+
+ ACE_Mem_Map *map (void) const;
+
+ void can_map (int);
+
+private:
+
+ ACE_SYNCH_MUTEX lock_;
+ ACE_Mem_Map *map_;
+
+ int can_map_;
+
+};
+
+#endif /* JAWS_FILE_H */
diff --git a/ACE/apps/JAWS3/jaws3/IO.cpp b/ACE/apps/JAWS3/jaws3/IO.cpp
new file mode 100644
index 00000000000..98e2e6e32f5
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/IO.cpp
@@ -0,0 +1,114 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif /*JAWS_BUILD_DLL*/
+
+#include "ace/OS_NS_strings.h"
+
+#include "jaws3/IO.h"
+#include "jaws3/Asynch_IO.h"
+#include "jaws3/Synch_IO.h"
+#include "jaws3/Reactive_IO.h"
+#include "jaws3/Options.h"
+
+JAWS_IO::JAWS_IO (JAWS_IO_Impl *impl)
+ : impl_ (impl)
+{
+ // Use synchronous IO by default. It is the most efficient
+ // in terms of calls needed, but provides the least amount
+ // of support for concurrency.
+
+ if (this->impl_ == 0)
+ {
+ const char *io_type = JAWS_Options::instance ()->getenv ("JAWS_IO");
+ if (io_type == 0)
+ io_type = JAWS_DEFAULT_IO;
+
+ if (ACE_OS::strcasecmp (io_type, "SYNCH") == 0)
+ this->impl_ = JAWS_Synch_IO::instance ();
+ else if (ACE_OS::strcasecmp (io_type, "ASYNCH") == 0)
+ this->impl_ = JAWS_Asynch_IO::instance ();
+ else if (ACE_OS::strcasecmp (io_type, "REACTIVE") == 0)
+ this->impl_ = JAWS_Reactive_IO::instance ();
+ else
+ this->impl_ = JAWS_Synch_IO::instance ();
+ }
+}
+
+JAWS_IO::~JAWS_IO (void)
+{
+}
+
+
+void
+JAWS_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->send (handle, mb, completer, act);
+}
+
+
+void
+JAWS_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->recv (handle, mb, completer, act);
+}
+
+
+void
+JAWS_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ this->impl_->transmit (handle, source, completer, act, header, trailer);
+}
+
+
+void
+JAWS_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+ this->impl_->send (handle, mb, completer, tv, act);
+}
+
+
+void
+JAWS_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+ this->impl_->recv (handle, mb, completer, tv, act);
+}
+
+
+void
+JAWS_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ this->impl_->transmit (handle, source, completer, tv, act, header, trailer);
+}
diff --git a/ACE/apps/JAWS3/jaws3/IO.h b/ACE/apps/JAWS3/jaws3/IO.h
new file mode 100644
index 00000000000..a910a4fb029
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/IO.h
@@ -0,0 +1,140 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_IO_H
+#define JAWS_IO_H
+
+#include "ace/Message_Block.h"
+#include "ace/Singleton.h"
+#include "ace/Synch_Traits.h"
+
+#include "jaws3/Export.h"
+
+
+class JAWS_IO;
+class JAWS_Event_Completer;
+
+
+class JAWS_Export JAWS_IO_Impl
+// = TITLE
+// IO inteface for the implementation classes on the RHS of the
+// Bridge Pattern.
+{
+public:
+
+ virtual ~JAWS_IO_Impl (void) {}
+
+ // = Regular IO methods.
+
+ virtual void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+
+ virtual void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+
+ virtual void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ ) = 0;
+
+ // = Timed IO methods.
+
+ virtual void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ ) = 0;
+
+ virtual void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ ) = 0;
+
+ virtual void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ ) = 0;
+
+};
+
+
+class JAWS_Export JAWS_IO
+{
+public:
+
+ JAWS_IO (JAWS_IO_Impl *impl = 0);
+
+ ~JAWS_IO (void);
+
+ static JAWS_IO * instance (void)
+ {
+ return ACE_Singleton<JAWS_IO, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+
+private:
+
+ JAWS_IO_Impl *impl_;
+
+};
+
+#endif /* JAWS_IO_H */
diff --git a/ACE/apps/JAWS3/jaws3/Makefile.am b/ACE/apps/JAWS3/jaws3/Makefile.am
new file mode 100644
index 00000000000..d140de85b12
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Makefile.am
@@ -0,0 +1,138 @@
+## Process this file with automake to create Makefile.in
+##
+## $Id$
+##
+## This file was generated by MPC. Any changes made directly to
+## this file will be lost the next time it is generated.
+##
+## MPC Command:
+## ./bin/mwc.pl -type automake -noreldefs ACE.mwc
+
+ACE_BUILDDIR = $(top_builddir)
+ACE_ROOT = $(top_srcdir)
+
+
+## Makefile.JAWS3.am
+
+if !BUILD_ACE_FOR_TAO
+if !BUILD_USES_WCHAR
+
+noinst_LTLIBRARIES = libJAWS3.la
+
+libJAWS3_la_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(srcdir)/.. \
+ -DJAWS_BUILD_DLL
+
+libJAWS3_la_SOURCES = \
+ Asynch_IO.cpp \
+ Concurrency.cpp \
+ Config_File.cpp \
+ Datagram.cpp \
+ Event_Completer.cpp \
+ Event_Dispatcher.cpp \
+ FILE.cpp \
+ IO.cpp \
+ Options.cpp \
+ Protocol_Handler.cpp \
+ Reactive_IO.cpp \
+ Signal_Task.cpp \
+ Symbol_Table.cpp \
+ Synch_IO.cpp \
+ THYBRID_Concurrency.cpp \
+ TPOOL_Concurrency.cpp \
+ TPR_Concurrency.cpp \
+ Task_Timer.cpp \
+ Templates.cpp \
+ Timer.cpp \
+ Timer_Helpers.cpp
+
+noinst_HEADERS = \
+ Asynch_IO.h \
+ Asynch_IO_Helpers.h \
+ Cached_Allocator_T.cpp \
+ Cached_Allocator_T.h \
+ Concurrency.h \
+ Concurrency_T.cpp \
+ Concurrency_T.h \
+ Config_File.h \
+ Datagram.h \
+ Event_Completer.h \
+ Event_Dispatcher.h \
+ Event_Result.h \
+ Export.h \
+ FILE.h \
+ IO.h \
+ Options.h \
+ Protocol_Handler.h \
+ Reactive_IO.h \
+ Reactive_IO_Helpers.h \
+ Signal_Task.h \
+ Symbol_Table.h \
+ Synch_IO.h \
+ THYBRID_Concurrency.h \
+ TPOOL_Concurrency.h \
+ TPR_Concurrency.h \
+ Task_Timer.h \
+ Timer.h \
+ Timer_Helpers.h
+
+endif !BUILD_USES_WCHAR
+endif !BUILD_ACE_FOR_TAO
+
+## Makefile.JAWS3_server.am
+
+if !BUILD_ACE_FOR_TAO
+if !BUILD_USES_WCHAR
+
+noinst_PROGRAMS = main
+
+main_CPPFLAGS = \
+ -I$(ACE_ROOT) \
+ -I$(ACE_BUILDDIR) \
+ -I$(srcdir)/..
+
+main_SOURCES = \
+ main.cpp \
+ Asynch_IO.h \
+ Asynch_IO_Helpers.h \
+ Cached_Allocator_T.h \
+ Concurrency.h \
+ Concurrency_T.h \
+ Config_File.h \
+ Datagram.h \
+ Event_Completer.h \
+ Event_Dispatcher.h \
+ Event_Result.h \
+ Export.h \
+ FILE.h \
+ IO.h \
+ Options.h \
+ Protocol_Handler.h \
+ Reactive_IO.h \
+ Reactive_IO_Helpers.h \
+ Signal_Task.h \
+ Symbol_Table.h \
+ Synch_IO.h \
+ THYBRID_Concurrency.h \
+ TPOOL_Concurrency.h \
+ TPR_Concurrency.h \
+ Task_Timer.h \
+ Timer.h \
+ Timer_Helpers.h
+
+main_LDADD = \
+ libJAWS3.la \
+ $(ACE_BUILDDIR)/ace/libACE.la
+
+endif !BUILD_USES_WCHAR
+endif !BUILD_ACE_FOR_TAO
+
+## Clean up template repositories, etc.
+clean-local:
+ -rm -f *~ *.bak *.rpo *.sym lib*.*_pure_* core core.*
+ -rm -f gcctemp.c gcctemp so_locations *.ics
+ -rm -rf cxx_repository ptrepository ti_files
+ -rm -rf templateregistry ir.out
+ -rm -rf ptrepository SunWS_cache Templates.DB
diff --git a/ACE/apps/JAWS3/jaws3/Options.cpp b/ACE/apps/JAWS3/jaws3/Options.cpp
new file mode 100644
index 00000000000..19c7a40406e
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Options.cpp
@@ -0,0 +1,25 @@
+// $Id$
+
+#include "ace/OS_NS_stdlib.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif /*JAWS_BUILD_DLL*/
+
+#include "jaws3/Options.h"
+
+JAWS_Options::JAWS_Options (void)
+{
+ this->cf_ = new JAWS_Config_File ("jaws.conf");
+}
+
+const char *
+JAWS_Options::getenv (const char *key)
+{
+ const char *value = 0;
+ if (this->cf_ == 0 || this->cf_->find (key, value) < 0)
+ value = ACE_OS::getenv (key);
+
+ return value;
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Options.h b/ACE/apps/JAWS3/jaws3/Options.h
new file mode 100644
index 00000000000..ff3720706ad
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Options.h
@@ -0,0 +1,40 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_OPTIONS_H
+#define JAWS_OPTIONS_H
+
+#include "ace/Singleton.h"
+#include "ace/Synch.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/Config_File.h"
+
+#define JAWS_DEFAULT_MIN_THYBRID_THREADS "1"
+#define JAWS_DEFAULT_MAX_THYBRID_THREADS "-1"
+#define JAWS_DEFAULT_TPOOL_THREADS "5"
+#define JAWS_DEFAULT_IO "SYNCH"
+#define JAWS_DEFAULT_CONCURRENCY "TPR"
+
+class JAWS_Options;
+
+class JAWS_Export JAWS_Options
+{
+public:
+
+ JAWS_Options (void);
+
+ const char *getenv (const char *key);
+
+ static JAWS_Options * instance (void)
+ {
+ return ACE_Singleton<JAWS_Options, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+private:
+
+ JAWS_Config_File *cf_;
+
+};
+
+#endif /* JAWS_OPTIONS_H */
diff --git a/ACE/apps/JAWS3/jaws3/Protocol_Handler.cpp b/ACE/apps/JAWS3/jaws3/Protocol_Handler.cpp
new file mode 100644
index 00000000000..4b2122b46d0
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Protocol_Handler.cpp
@@ -0,0 +1,65 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Protocol_Handler.h"
+#include "jaws3/Concurrency.h"
+
+JAWS_Protocol_State::~JAWS_Protocol_State (void)
+{
+}
+
+
+JAWS_Protocol_Handler::JAWS_Protocol_Handler ( JAWS_Protocol_State *state
+ , void *data
+ )
+ : state_ (state)
+ , data_ (data)
+ , mb_ (& this->db_)
+{
+ this->db_.base ((char *) this, 0 /* an infinite queue */);
+}
+
+
+JAWS_Protocol_Handler::~JAWS_Protocol_Handler (void)
+{
+ this->mb_.replace_data_block (0);
+}
+
+
+int
+JAWS_Protocol_Handler::service (void)
+{
+ if (this->state_ == 0)
+ return -1;
+
+ return this->state_->service (this, this->data_);
+}
+
+
+void
+JAWS_Protocol_Handler::event_complete ( const JAWS_Event_Result &result
+ , void *act
+ )
+{
+ // This call is done in the context of the dispatching
+ // thread (e.g., by the Reactor thread, or by one of the
+ // threads in the Proactor, or by the invoker of the IO
+ // if the IO is synchronous).
+
+ this->state_ = this->state_->transition (result, this->data_, act);
+
+ // At this point, we need to cue this Handler back into
+ // the concurrency mechanism. This probably means the
+ // Message Queue of some Concurrency Task.
+
+ JAWS_Concurrency::instance ()->putq (this);
+
+ // Doing it this way is less efficient than calling into
+ // the service() method of the next state directly from
+ // here, but it gains the flexibility of a more modular
+ // concurrency mechanism.
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Protocol_Handler.h b/ACE/apps/JAWS3/jaws3/Protocol_Handler.h
new file mode 100644
index 00000000000..68439365c92
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Protocol_Handler.h
@@ -0,0 +1,80 @@
+// $Id$
+#ifndef JAWS_PROTOCOL_HANDLER_H
+#define JAWS_PROTOCOL_HANDLER_H
+
+#include "ace/Message_Block.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/Event_Completer.h"
+
+
+class JAWS_Export JAWS_Protocol_State
+{
+
+ friend class JAWS_Protocol_Handler;
+
+public:
+
+ virtual ~JAWS_Protocol_State (void);
+
+protected:
+
+ virtual int service (JAWS_Event_Completer *, void *data) = 0;
+
+ virtual JAWS_Protocol_State * transition ( const JAWS_Event_Result &
+ , void *data
+ , void *act
+ ) = 0;
+
+};
+
+class JAWS_Export JAWS_Protocol_Handler
+ : public JAWS_Event_Completer
+// = TITLE
+// Abstraction that interacts with concurrency dispatching.
+{
+
+ friend class JAWS_TPOOL_Concurrency;
+ friend class JAWS_TPR_Concurrency;
+ friend class JAWS_THYBRID_Concurrency;
+
+public:
+
+ JAWS_Protocol_Handler (JAWS_Protocol_State *state = 0, void *data = 0);
+
+ virtual int service (void);
+
+ virtual void dismiss (void)
+ {
+ delete this;
+ }
+
+protected:
+
+ virtual ~JAWS_Protocol_Handler (void);
+ // Try to guarantee this class will be created dynamically.
+
+protected:
+
+ void event_complete (const JAWS_Event_Result &result, void *act);
+ // The event completion routine that triggers the transition
+ // to the next Protocol State.
+
+ void default_complete (const JAWS_Event_Result &result, void *act)
+ {
+ this->event_complete (result, act);
+ }
+
+private:
+
+ JAWS_Protocol_State *state_;
+
+ void *data_;
+
+ ACE_Data_Block db_;
+ ACE_Message_Block mb_;
+
+};
+
+
+#endif /* JAWS_PROTOCOL_HANDLER_H */
diff --git a/ACE/apps/JAWS3/jaws3/Reactive_IO.cpp b/ACE/apps/JAWS3/jaws3/Reactive_IO.cpp
new file mode 100644
index 00000000000..ead383efa24
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Reactive_IO.cpp
@@ -0,0 +1,601 @@
+// $Id$
+
+#include "ace/ACE.h"
+#include "ace/OS_NS_unistd.h"
+#include "ace/Reactor.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/IO.h"
+#include "jaws3/Reactive_IO.h"
+#include "jaws3/Reactive_IO_Helpers.h"
+#include "jaws3/Event_Completer.h"
+
+void
+JAWS_Reactive_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+ if (mb->length () == 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_SEND_OK
+ );
+ if (completer)
+ completer->output_complete (io_result, act);
+
+ return;
+ }
+
+ JAWS_IO_Reactive_Send *rs;
+ rs = JAWS_IO_Reactive_Send::make (handle, mb, completer, tv, act);
+
+ if (rs == 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_FAIL
+ );
+ if (completer)
+ completer->output_complete (io_result, act);
+
+ return;
+ }
+
+ rs->open ();
+}
+
+void
+JAWS_Reactive_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->send (handle, mb, completer, ACE_Time_Value::zero, act);
+}
+
+
+void
+JAWS_Reactive_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+
+ JAWS_IO_Reactive_Recv *rr;
+ rr = JAWS_IO_Reactive_Recv::make (handle, mb, completer, tv, act);
+
+ if (rr == 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_RECV_FAIL
+ );
+ if (completer)
+ completer->output_complete (io_result, act);
+
+ return;
+ }
+
+ rr->open ();
+}
+
+
+void
+JAWS_Reactive_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->recv (handle, mb, completer, ACE_Time_Value::zero, act);
+}
+
+
+void
+JAWS_Reactive_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ JAWS_IO_Reactive_Transmit *rt;
+ rt = JAWS_IO_Reactive_Transmit::make ( handle
+ , source
+ , completer
+ , tv
+ , header
+ , trailer
+ , act
+ );
+
+ if (rt == 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_FAIL
+ );
+ if (completer)
+ completer->output_complete (io_result, act);
+
+ return;
+ }
+
+ rt->open ();
+}
+
+
+void
+JAWS_Reactive_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ this->transmit ( handle
+ , source
+ , completer
+ , ACE_Time_Value::zero
+ , act
+ , header
+ , trailer
+ );
+}
+
+
+void
+JAWS_IO_Reactive_Handler::open (void)
+{
+ int result = ACE_Reactor::instance ()->notify (this);
+
+ if (result < 0)
+ this->close (result);
+}
+
+void
+JAWS_IO_Reactive_Handler::close (int result)
+{
+ if (result < 0)
+ {
+ if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::WRITE_MASK))
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_FAIL
+ );
+ this->io_result_ = io_result;
+ }
+ else if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::READ_MASK))
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_RECV_FAIL
+ );
+ this->io_result_ = io_result;
+ }
+
+ this->handle_close (this->handle_, this->mask_);
+ }
+}
+
+int
+JAWS_IO_Reactive_Handler::handle_timeout (const ACE_Time_Value &, const void *)
+{
+ if (this->was_active_)
+ {
+ this->was_active_ = 0;
+
+ this->timer_id_ =
+ ACE_Reactor::instance ()->schedule_timer (this, 0, this->tv_);
+
+ return 0;
+ }
+
+ ACE_Reactor::instance ()
+ ->remove_handler ( this
+ , ACE_Event_Handler::RWE_MASK|ACE_Event_Handler::DONT_CALL
+ );
+
+ this->timer_id_ = -1;
+
+ if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::WRITE_MASK))
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_TIMEOUT
+ , ETIME
+ );
+ this->io_result_ = io_result;
+ }
+ else if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::READ_MASK))
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_RECV_TIMEOUT
+ , ETIME
+ );
+ this->io_result_ = io_result;
+ }
+
+ return -1;
+}
+
+int
+JAWS_IO_Reactive_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
+{
+ if (this->completer_)
+ {
+ if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::WRITE_MASK))
+ this->completer_->output_complete (this->io_result_, this->act_);
+ else if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::READ_MASK))
+ this->completer_->input_complete (this->io_result_, this->act_);
+ }
+
+ ACE_Reactor::instance ()
+ ->remove_handler ( this
+ , ACE_Event_Handler::RWE_MASK|ACE_Event_Handler::DONT_CALL
+ );
+
+ delete this;
+ return 0;
+}
+
+int
+JAWS_IO_Reactive_Handler::handle_exception (ACE_HANDLE handle)
+{
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ // We are being called back from a notify call.
+ // This is our cue to register ourselves with the Reactor.
+
+ int result;
+ result =
+ ACE_Reactor::instance ()
+ ->register_handler (this, this->mask_|ACE_Event_Handler::EXCEPT_MASK);
+
+ if (result < 0)
+ this->close (result);
+
+ return 0;
+ }
+
+ // back to our regularly scheduled except mask handling.
+
+ if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::WRITE_MASK))
+ {
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_SHORT
+ );
+ this->io_result_ = io_result;
+ }
+ else if (ACE_BIT_ENABLED (this->mask_, ACE_Event_Handler::READ_MASK))
+ {
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_RECV_SHORT
+ );
+ this->io_result_ = io_result;
+ }
+
+ return -1;
+}
+
+
+int
+JAWS_IO_Reactive_Send::handle_output (ACE_HANDLE handle)
+{
+ this->was_active_ = 1;
+
+ ssize_t count = ACE::send ( handle
+ , this->mb_->rd_ptr ()
+ , this->mb_->length ()
+ );
+
+ if (count <= 0 && this->bytes_ == 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_FAIL
+ );
+ this->io_result_ = io_result;
+ }
+ else if (count <= 0 && this->bytes_ > 0)
+ {
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_SHORT
+ );
+ this->io_result_ = io_result;
+ }
+ else
+ {
+ if (count > 0)
+ this->mb_->rd_ptr (count);
+
+ this->bytes_ += count;
+
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_SEND_OK
+ );
+ this->io_result_ = io_result;
+ }
+
+ if (count <= 0 || this->mb_->length () == 0)
+ return -1;
+
+ // Not done yet, so stay registered.
+ return 0;
+}
+
+
+int
+JAWS_IO_Reactive_Recv::handle_input (ACE_HANDLE handle)
+{
+ ssize_t count = ACE::recv ( handle
+ , this->mb_->wr_ptr ()
+ , this->mb_->space ()
+ );
+
+ if (count < 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_RECV_FAIL
+ );
+ this->io_result_ = io_result;
+ }
+ else
+ {
+ if (count > 0)
+ this->mb_->wr_ptr (count);
+
+ JAWS_Event_Result io_result ( count
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_RECV_OK
+ );
+ this->io_result_ = io_result;
+ }
+
+ return -1;
+}
+
+
+int
+JAWS_IO_Reactive_Transmit::handle_output (ACE_HANDLE handle)
+{
+ this->was_active_ = 1;
+
+ if (this->header_ && this->header_->length () > 0)
+ return this->handle_output_header (handle);
+ else
+ this->header_ = 0;
+
+ if (this->source_ != ACE_INVALID_HANDLE)
+ return this->handle_output_source (handle);
+
+ if (this->trailer_ && this->trailer_->length () > 0)
+ return this->handle_output_trailer (handle);
+ else
+ this->trailer_ = 0;
+
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_TRANSMIT_OK
+ );
+ this->io_result_ = io_result;
+
+ return -1;
+}
+
+int
+JAWS_IO_Reactive_Transmit::handle_output_header (ACE_HANDLE handle)
+{
+ return this->handle_output_mb (handle, this->header_);
+}
+
+int
+JAWS_IO_Reactive_Transmit::handle_output_source (ACE_HANDLE handle)
+{
+ ACE_Message_Block *mb = this->source_buf_;
+
+ // Try to read data into the mb if data is still available.
+ if (mb->space () && this->source_ != ACE_INVALID_HANDLE)
+ {
+ ssize_t count;
+ count = ACE_OS::read (this->source_, mb->wr_ptr (), mb->space ());
+
+ if (count < 0)
+ {
+ this->source_ = ACE_INVALID_HANDLE;
+ this->source_buf_ = 0;
+
+ if (this->bytes_ == 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_FAIL
+ );
+ this->io_result_ = io_result;
+ }
+ else if (this->bytes_ > 0)
+ {
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_SHORT
+ );
+ this->io_result_ = io_result;
+ }
+
+ return -1;
+ }
+ else if (count == 0)
+ this->source_ = ACE_INVALID_HANDLE;
+ else
+ mb->wr_ptr (count);
+ }
+
+ int result = 0;
+
+ if (mb->length () > 0)
+ result = this->handle_output_mb (handle, mb);
+
+ if (result < 0)
+ {
+ this->source_ = ACE_INVALID_HANDLE;
+ this->source_buf_ = 0;
+ }
+ else if (mb == 0 && this->source_ == ACE_INVALID_HANDLE)
+ this->source_buf_ = 0;
+ else
+ this->source_buf_->crunch ();
+
+ return result;
+}
+
+int
+JAWS_IO_Reactive_Transmit::handle_output_trailer (ACE_HANDLE handle)
+{
+ int result = this->handle_output_mb (handle, this->trailer_);
+
+ if (result == 0 && this->trailer_ == 0)
+ {
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_SHORT
+ );
+ this->io_result_ = io_result;
+ return -1;
+ }
+
+ return result;
+}
+
+int
+JAWS_IO_Reactive_Transmit::handle_output_mb ( ACE_HANDLE handle
+ , ACE_Message_Block *&mb
+ )
+{
+ ssize_t count = ACE::send (handle, mb->rd_ptr (), mb->length ());
+
+ if (count <= 0 && this->bytes_ == 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_FAIL
+ );
+ this->io_result_ = io_result;
+ }
+ else if (count <= 0 && this->bytes_ > 0)
+ {
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_SHORT
+ );
+ this->io_result_ = io_result;
+ }
+ else
+ {
+ mb->rd_ptr (count);
+ this->bytes_ += count;
+ }
+
+ if (count <= 0)
+ return -1;
+
+ if (mb->length () == 0)
+ mb = 0;
+
+ return 0;
+}
+
+void
+JAWS_IO_Reactive_Transmit::close (int result)
+{
+ if (result < 0)
+ {
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_FAIL
+ );
+ this->io_result_ = io_result;
+
+ this->handle_close (this->handle_, this->mask_);
+ }
+}
+
+int
+JAWS_IO_Reactive_Transmit::handle_timeout (const ACE_Time_Value &, const void *)
+{
+ if (this->was_active_)
+ {
+ this->was_active_ = 0;
+
+ this->timer_id_ =
+ ACE_Reactor::instance ()->schedule_timer (this, 0, this->tv_);
+
+ return 0;
+ }
+
+ ACE_Reactor::instance ()
+ ->remove_handler ( this
+ , ACE_Event_Handler::RWE_MASK|ACE_Event_Handler::DONT_CALL
+ );
+
+ this->timer_id_ = -1;
+
+ JAWS_Event_Result io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_TIMEOUT
+ , ETIME
+ );
+
+ this->io_result_ = io_result;
+
+ return -1;
+}
+
+int
+JAWS_IO_Reactive_Transmit::handle_exception (ACE_HANDLE handle)
+{
+ if (handle == ACE_INVALID_HANDLE)
+ {
+ // We are being called back from a notify call.
+ // This is our cue to register ourselves with the Reactor.
+
+ int result;
+ result =
+ ACE_Reactor::instance ()
+ ->register_handler (this, this->mask_|ACE_Event_Handler::EXCEPT_MASK);
+
+ if (result < 0)
+ this->close (result);
+
+ return 0;
+ }
+
+ // back to our regularly scheduled except mask handling.
+
+ JAWS_Event_Result io_result ( this->bytes_
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TRANSMIT_SHORT
+ );
+ this->io_result_ = io_result;
+
+ return -1;
+}
diff --git a/ACE/apps/JAWS3/jaws3/Reactive_IO.h b/ACE/apps/JAWS3/jaws3/Reactive_IO.h
new file mode 100644
index 00000000000..e899357e5fc
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Reactive_IO.h
@@ -0,0 +1,72 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_REACTIVE_IO_H
+#define JAWS_REACTIVE_IO_H
+
+#include "ace/Message_Block.h"
+#include "ace/Singleton.h"
+#include "ace/Synch_Traits.h"
+#include "ace/Time_Value.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/IO.h"
+#include "jaws3/Event_Result.h"
+
+class JAWS_Reactive_IO;
+
+class JAWS_Export JAWS_Reactive_IO : public JAWS_IO_Impl
+{
+public:
+
+ static JAWS_Reactive_IO * instance (void)
+ {
+ return ACE_Singleton<JAWS_Reactive_IO, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+};
+
+#endif /* JAWS_REACTIVE_IO_H */
diff --git a/ACE/apps/JAWS3/jaws3/Reactive_IO_Helpers.h b/ACE/apps/JAWS3/jaws3/Reactive_IO_Helpers.h
new file mode 100644
index 00000000000..9f94fd4caaf
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Reactive_IO_Helpers.h
@@ -0,0 +1,308 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_REACTIVE_IO_HELPERS_H
+#define JAWS_REACTIVE_IO_HELPERS_H
+
+#include "ace/Event_Handler.h"
+#include "ace/Message_Block.h"
+#include "ace/Singleton.h"
+#include "ace/Time_Value.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/IO.h"
+#include "jaws3/Event_Result.h"
+#include "jaws3/Event_Completer.h"
+
+class JAWS_Reactive_IO;
+
+class JAWS_IO_Reactive_Handler : public ACE_Event_Handler
+{
+
+ friend class JAWS_IO_Reactive_Send;
+ friend class JAWS_IO_Reactive_Recv;
+ friend class JAWS_IO_Reactive_Transmit;
+
+public:
+
+ virtual void open (void);
+
+ int handle_timeout (const ACE_Time_Value &, const void *);
+
+ int handle_close (ACE_HANDLE, ACE_Reactor_Mask);
+
+ int handle_exception (ACE_HANDLE);
+
+ ACE_HANDLE get_handle (void) const { return this->handle_; }
+
+ void set_handle (ACE_HANDLE handle) { this->handle_ = handle; }
+
+protected:
+
+ virtual void close (int result);
+
+private:
+
+ JAWS_IO_Reactive_Handler ( ACE_HANDLE handle
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ , ACE_Reactor_Mask mask
+ )
+ : bytes_ (0)
+ , handle_ (handle)
+ , completer_ (completer)
+ , tv_ (tv)
+ , act_ (act)
+ , mask_ (mask)
+ , timer_id_ (-1)
+ , was_active_ (0)
+ {
+ if (ACE_Time_Value::zero < this->tv_)
+ this->timer_id_ =
+ ACE_Reactor::instance ()->schedule_timer (this, 0, this->tv_);
+ }
+
+public: // needed for destructor due to "aCC: HP ANSI C++ B3910B A.03.39" compiler bug
+
+ ~JAWS_IO_Reactive_Handler (void)
+ {
+ if (this->timer_id_ != -1)
+ ACE_Reactor::instance ()->cancel_timer (this->timer_id_);
+ }
+
+private:
+
+ JAWS_Event_Result io_result_;
+
+ size_t bytes_;
+ ACE_HANDLE handle_;
+ JAWS_Event_Completer *completer_;
+ ACE_Time_Value tv_;
+ void *act_;
+
+ ACE_Reactor_Mask mask_;
+ long timer_id_;
+
+ int was_active_;
+
+};
+
+
+class JAWS_IO_Reactive_Send : public JAWS_IO_Reactive_Handler
+{
+
+ friend class JAWS_Reactive_IO;
+
+public:
+
+ int handle_output (ACE_HANDLE handle);
+
+ static JAWS_IO_Reactive_Send * make ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+ {
+ return new JAWS_IO_Reactive_Send ( handle
+ , mb
+ , completer
+ , ACE_Time_Value::zero
+ , act
+ , ACE_Event_Handler::WRITE_MASK
+ );
+ }
+
+ static JAWS_IO_Reactive_Send * make ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+ {
+ return new JAWS_IO_Reactive_Send ( handle
+ , mb
+ , completer
+ , tv
+ , act
+ , ACE_Event_Handler::WRITE_MASK
+ );
+ }
+
+private:
+
+ JAWS_IO_Reactive_Send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ , ACE_Reactor_Mask mask
+ )
+ : JAWS_IO_Reactive_Handler (handle, completer, tv, act, mask)
+ , mb_ (mb)
+ {
+ }
+
+private:
+
+ ACE_Message_Block *mb_;
+
+};
+
+
+class JAWS_IO_Reactive_Recv : public JAWS_IO_Reactive_Handler
+{
+
+ friend class JAWS_Reactive_IO;
+
+public:
+
+ int handle_input (ACE_HANDLE handle);
+
+ static JAWS_IO_Reactive_Recv * make ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+ {
+ return new JAWS_IO_Reactive_Recv ( handle
+ , mb
+ , completer
+ , ACE_Time_Value::zero
+ , act
+ , ACE_Event_Handler::READ_MASK
+ );
+ }
+
+ static JAWS_IO_Reactive_Recv * make ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+ {
+ return new JAWS_IO_Reactive_Recv ( handle
+ , mb
+ , completer
+ , tv
+ , act
+ , ACE_Event_Handler::READ_MASK
+ );
+ }
+
+private:
+
+ JAWS_IO_Reactive_Recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ , ACE_Reactor_Mask mask
+ )
+ : JAWS_IO_Reactive_Handler (handle, completer, tv, act, mask)
+ , mb_ (mb)
+ {
+ }
+
+private:
+
+ ACE_Message_Block *mb_;
+
+};
+
+
+class JAWS_IO_Reactive_Transmit : public JAWS_IO_Reactive_Handler
+{
+
+ friend class JAWS_Reactive_IO;
+
+public:
+
+ int handle_timeout (const ACE_Time_Value &, const void *);
+
+ int handle_output (ACE_HANDLE handle);
+
+ int handle_exception (ACE_HANDLE handle);
+
+ static JAWS_IO_Reactive_Transmit * make ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ , void *act
+ )
+ {
+ return new JAWS_IO_Reactive_Transmit ( handle
+ , source
+ , completer
+ , ACE_Time_Value::zero
+ , header
+ , trailer
+ , act
+ , ACE_Event_Handler::WRITE_MASK
+ );
+ }
+
+ static JAWS_IO_Reactive_Transmit * make ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ , void *act
+ )
+ {
+ return new JAWS_IO_Reactive_Transmit ( handle
+ , source
+ , completer
+ , tv
+ , header
+ , trailer
+ , act
+ , ACE_Event_Handler::WRITE_MASK
+ );
+ }
+
+protected:
+
+ void close (int result);
+
+ int handle_output_header (ACE_HANDLE handle);
+
+ int handle_output_source (ACE_HANDLE handle);
+
+ int handle_output_trailer (ACE_HANDLE handle);
+
+ int handle_output_mb (ACE_HANDLE handle, ACE_Message_Block *&mb);
+
+private:
+
+ JAWS_IO_Reactive_Transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ , void *act
+ , ACE_Reactor_Mask mask
+ )
+ : JAWS_IO_Reactive_Handler (handle, completer, tv, act, mask)
+ , source_ (source)
+ , source_mb_ (8 * 1024)
+ , source_buf_ (& this->source_mb_)
+ , header_ (header)
+ , trailer_ (trailer)
+ {
+ }
+
+private:
+
+ ACE_HANDLE source_;
+ ACE_Message_Block source_mb_;
+ ACE_Message_Block *source_buf_;
+ ACE_Message_Block *header_;
+ ACE_Message_Block *trailer_;
+
+};
+
+#endif /* JAWS_REACTIVE_IO_HELPERS_H */
diff --git a/ACE/apps/JAWS3/jaws3/Signal_Task.cpp b/ACE/apps/JAWS3/jaws3/Signal_Task.cpp
new file mode 100644
index 00000000000..24c79eec032
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Signal_Task.cpp
@@ -0,0 +1,83 @@
+// $Id$
+
+#include "ace/OS_NS_signal.h"
+#include "ace/OS_NS_Thread.h"
+#include "ace/Thread.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Signal_Task.h"
+#include "jaws3/Event_Dispatcher.h"
+#include "jaws3/THYBRID_Concurrency.h"
+#include "jaws3/TPOOL_Concurrency.h"
+#include "jaws3/TPR_Concurrency.h"
+
+
+ACE_THR_FUNC_RETURN
+JAWS_Signal_Task_function (void *)
+{
+ int done = 0;
+
+ while (! done)
+ {
+ int signo = ACE_OS::sigwait (JAWS_Signal_Task::instance ()->sigset ());
+
+ switch (signo)
+ {
+ case SIGINT:
+ case SIGTERM:
+
+ JAWS_Concurrency::instance ()->shutdown ();
+ JAWS_Event_Dispatcher::end_event_loop ();
+
+ done = 1;
+
+ break;
+# if !defined (ACE_WIN32)
+ case SIGHUP:
+ // In the future, re-read jaws.conf and svc.conf,
+ // and then reset the JAWS singletons.
+ // For now, just ignore it.
+ break;
+
+ case SIGPIPE:
+#endif // !defined (ACE_WIN32)
+ default:
+ break;
+
+ }
+
+ }
+
+ return 0;
+}
+
+
+JAWS_Signal_Task::JAWS_Signal_Task (void)
+{
+ // Set our signal mask.
+ this->sigset_.empty_set ();
+
+ this->sigset_.sig_add (SIGINT);
+ this->sigset_.sig_add (SIGTERM);
+ this->sigset_.sig_add (SIGPIPE);
+
+#if 0
+ this->sigset_.fill_set ();
+#endif
+
+ ACE_OS::sigprocmask (SIG_BLOCK, this->sigset_, 0);
+
+ int result;
+ result = ACE_Thread::spawn ( JAWS_Signal_Task_function
+ , 0
+ , THR_BOUND
+ );
+ if (result < 0)
+ {
+ ACE_ERROR ((LM_ERROR, "%p\n", "ACE_Thread::spawn"));
+ return;
+ }
+}
diff --git a/ACE/apps/JAWS3/jaws3/Signal_Task.h b/ACE/apps/JAWS3/jaws3/Signal_Task.h
new file mode 100644
index 00000000000..f1564b812a0
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Signal_Task.h
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_SIGNAL_TASK_H
+#define JAWS_SIGNAL_TASK_H
+
+#include "ace/Synch.h"
+#include "ace/Signal.h"
+#include "ace/Singleton.h"
+
+#include "jaws3/Export.h"
+
+class JAWS_Export JAWS_Signal_Task
+{
+public:
+
+ JAWS_Signal_Task (void);
+
+ static JAWS_Signal_Task * instance (void)
+ {
+ return ACE_Singleton<JAWS_Signal_Task, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ ACE_Sig_Set & sigset (void) { return this->sigset_; }
+
+private:
+
+ ACE_Sig_Set sigset_;
+
+};
+
+#endif /* JAWS_SIGNAL_TASK_H */
diff --git a/ACE/apps/JAWS3/jaws3/Symbol_Table.cpp b/ACE/apps/JAWS3/jaws3/Symbol_Table.cpp
new file mode 100644
index 00000000000..94e35254cb7
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Symbol_Table.cpp
@@ -0,0 +1,12 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Symbol_Table.h"
+
+JAWS_Symbol_Table::JAWS_Symbol_Table (size_t size)
+ : JAWS_SYMBOL_TABLE_BASE (size)
+{
+}
diff --git a/ACE/apps/JAWS3/jaws3/Symbol_Table.h b/ACE/apps/JAWS3/jaws3/Symbol_Table.h
new file mode 100644
index 00000000000..dfd856205e3
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Symbol_Table.h
@@ -0,0 +1,53 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_SYMBOL_TABLE_H
+#define JAWS_SYMBOL_TABLE_H
+
+#include "ace/Hash_Map_Manager.h"
+#include "ace/Synch.h"
+
+#include "jaws3/Export.h"
+
+#define JAWS_SYMBOL_TABLE_ENTRY \
+ ACE_Hash_Map_Entry <const ACE_TCHAR *, const ACE_TCHAR *>
+
+#define JAWS_SYMBOL_TABLE_BASE \
+ ACE_Hash_Map_Manager_Ex<const ACE_TCHAR *, const ACE_TCHAR *, \
+ ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, \
+ ACE_SYNCH_NULL_MUTEX>
+
+#define JAWS_SYMBOL_TABLE_ITERATOR_BASE \
+ ACE_Hash_Map_Iterator_Base_Ex<const ACE_TCHAR *, const ACE_TCHAR *, \
+ ACE_Hash<const ACE_TCHAR *>, \
+ ACE_Equal_To<const ACE_TCHAR *>, \
+ ACE_SYNCH_NULL_MUTEX>
+
+#define JAWS_SYMBOL_TABLE_ITERATOR \
+ ACE_Hash_Map_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, \
+ ACE_Hash<const ACE_TCHAR *>, ACE_Equal_To<const ACE_TCHAR *>, \
+ ACE_SYNCH_NULL_MUTEX>
+
+#define JAWS_SYMBOL_TABLE_REVERSE_ITERATOR \
+ ACE_Hash_Map_Reverse_Iterator_Ex<const ACE_TCHAR *, const ACE_TCHAR *, \
+ ACE_Hash<const ACE_TCHAR *>, \
+ ACE_Equal_To<const ACE_TCHAR *>, \
+ ACE_SYNCH_NULL_MUTEX>
+
+class JAWS_Symbol_Table;
+
+class JAWS_Export JAWS_Symbol_Table : public JAWS_SYMBOL_TABLE_BASE
+
+// = TITLE
+// A class the associates a string with another string.
+{
+public:
+
+ // = Initialization methods
+
+ JAWS_Symbol_Table (size_t size = 211);
+ // Hash table <size> should be a prime.
+
+};
+
+#endif /* JAWS_SYMBOL_TABLE_H */
diff --git a/ACE/apps/JAWS3/jaws3/Synch_IO.cpp b/ACE/apps/JAWS3/jaws3/Synch_IO.cpp
new file mode 100644
index 00000000000..69b0d92fd95
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Synch_IO.cpp
@@ -0,0 +1,265 @@
+// $Id$
+
+#include "ace/ACE.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/IO.h"
+#include "jaws3/Synch_IO.h"
+#include "jaws3/Event_Completer.h"
+
+static JAWS_Event_Result
+JAWS_synch_send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , const ACE_Time_Value *tv = 0
+ )
+{
+ JAWS_Event_Result io_result;
+
+ ssize_t result = ACE::send_n (handle, mb->rd_ptr (), mb->length (), tv);
+ if (result < 0)
+ {
+ if (errno == ETIME)
+ {
+ JAWS_Event_Result tmp_io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_TIMEOUT
+ );
+ io_result = tmp_io_result;
+ }
+ else
+ {
+ JAWS_Event_Result tmp_io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_FAIL
+ );
+ io_result = tmp_io_result;
+ }
+ }
+ else if ((size_t) result < mb->length ())
+ {
+ if (result > 0)
+ mb->rd_ptr (result);
+
+ JAWS_Event_Result tmp_io_result ( result
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_SHORT
+ );
+ io_result = tmp_io_result;
+ }
+ else
+ {
+ if (result > 0)
+ mb->rd_ptr (result);
+
+ JAWS_Event_Result tmp_io_result ( result
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_SEND_OK
+ );
+ io_result = tmp_io_result;
+ }
+
+ return io_result;
+}
+
+void
+JAWS_Synch_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+ JAWS_Event_Result io_result;
+ const ACE_Time_Value *tvp = 0;
+
+ if (ACE_Time_Value::zero < tv)
+ tvp = &tv;
+
+ io_result = JAWS_synch_send (handle, mb, tvp);
+
+ if (completer)
+ completer->output_complete (io_result, act);
+}
+
+
+void
+JAWS_Synch_IO::send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->send (handle, mb, completer, ACE_Time_Value::zero, act);
+}
+
+
+void
+JAWS_Synch_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ )
+{
+ JAWS_Event_Result io_result;
+ const ACE_Time_Value *tvp = 0;
+
+ if (ACE_Time_Value::zero < tv)
+ tvp = &tv;
+
+ ssize_t result = ACE::recv (handle, mb->wr_ptr (), mb->space (), tvp);
+ if (result < 0)
+ {
+ JAWS_Event_Result tmp_io_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_RECV_FAIL
+ );
+ io_result = tmp_io_result;
+ }
+ else
+ {
+ if (result > 0)
+ mb->wr_ptr (result);
+
+ JAWS_Event_Result tmp_io_result ( result
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_RECV_OK
+ );
+ io_result = tmp_io_result;
+ }
+
+ if (completer)
+ completer->input_complete (io_result, act);
+}
+
+
+void
+JAWS_Synch_IO::recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->recv (handle, mb, completer, ACE_Time_Value::zero, act);
+}
+
+
+void
+JAWS_Synch_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ JAWS_Event_Result io_result;
+ const ACE_Time_Value *tvp = 0;
+
+ if (ACE_Time_Value::zero < tv)
+ tvp = &tv;
+
+ size_t bytes = 0;
+
+ if (header)
+ {
+ io_result = JAWS_synch_send (handle, header, tvp);
+ bytes += io_result.bytes ();
+ if (io_result.status () != JAWS_Event_Result::JE_OK)
+ {
+ if (completer)
+ completer->input_complete (io_result, act);
+
+ return;
+ }
+ }
+
+ ACE_Message_Block buf (8 * 1024);
+ ssize_t len = 0;
+ while ((len = ACE::recv (source, buf.wr_ptr (), buf.space (), tvp)) >= 0)
+ {
+ if (len == 0)
+ break;
+
+ buf.wr_ptr (len);
+ io_result = JAWS_synch_send (handle, & buf);
+ bytes += io_result.bytes ();
+ if (io_result.status () != JAWS_Event_Result::JE_OK)
+ {
+ JAWS_Event_Result tmp_io_result ( bytes
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_SHORT
+ );
+
+ if (completer)
+ completer->input_complete (tmp_io_result, act);
+
+ return;
+ }
+
+ buf.crunch ();
+ }
+
+ if (trailer)
+ {
+ io_result = JAWS_synch_send (handle, trailer, tvp);
+ bytes += io_result.bytes ();
+ if (io_result.status () != JAWS_Event_Result::JE_OK)
+ {
+ JAWS_Event_Result tmp_io_result ( bytes
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_SHORT
+ );
+
+ if (completer)
+ completer->input_complete (tmp_io_result, act);
+
+ return;
+ }
+ }
+
+ if (len == 0)
+ {
+ JAWS_Event_Result tmp_io_result ( bytes
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_SEND_OK
+ );
+ io_result = tmp_io_result;
+ }
+ else
+ {
+ JAWS_Event_Result tmp_io_result ( bytes
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_SEND_SHORT
+ );
+ io_result = tmp_io_result;
+ }
+
+ if (completer)
+ completer->input_complete (io_result, act);
+}
+
+
+void
+JAWS_Synch_IO::transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act
+ , ACE_Message_Block *header
+ , ACE_Message_Block *trailer
+ )
+{
+ this->transmit ( handle
+ , source
+ , completer
+ , ACE_Time_Value::zero
+ , act
+ , header
+ , trailer
+ );
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Synch_IO.h b/ACE/apps/JAWS3/jaws3/Synch_IO.h
new file mode 100644
index 00000000000..5ecf5267088
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Synch_IO.h
@@ -0,0 +1,65 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_SYNCH_IO_H
+#define JAWS_SYNCH_IO_H
+
+#include "ace/Singleton.h"
+
+#include "jaws3/IO.h"
+
+class JAWS_Export JAWS_Synch_IO : public JAWS_IO_Impl
+{
+public:
+
+ static JAWS_Synch_IO * instance (void)
+ {
+ return ACE_Singleton<JAWS_Synch_IO, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+ void send ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void recv ( ACE_HANDLE handle
+ , ACE_Message_Block *mb
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ );
+
+ void transmit ( ACE_HANDLE handle
+ , ACE_HANDLE source
+ , JAWS_Event_Completer *completer
+ , const ACE_Time_Value &tv
+ , void *act = 0
+ , ACE_Message_Block *header = 0
+ , ACE_Message_Block *trailer = 0
+ );
+
+};
+
+#endif /* JAWS_SYNCH_IO_H */
diff --git a/ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.cpp b/ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.cpp
new file mode 100644
index 00000000000..83c3da28bc7
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.cpp
@@ -0,0 +1,130 @@
+// $Id$
+
+#include "ace/OS_NS_stdlib.h"
+#include "ace/Message_Block.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Concurrency.h"
+#include "jaws3/THYBRID_Concurrency.h"
+#include "jaws3/Protocol_Handler.h"
+#include "jaws3/Options.h"
+
+
+JAWS_THYBRID_Concurrency::JAWS_THYBRID_Concurrency (void)
+ : getting_ (0)
+ , min_number_of_threads_ (1)
+ , max_number_of_threads_ (-1)
+ , shutdown_task_ (0)
+ , error_ (0)
+{
+ const char *value;
+
+ value = JAWS_Options::instance ()->getenv ("JAWS_MIN_THYBRID_THREADS");
+ if (value != 0)
+ this->min_number_of_threads_ = ACE_OS::atoi (value);
+ else
+ this->min_number_of_threads_ =
+ ACE_OS::atoi (JAWS_DEFAULT_MIN_THYBRID_THREADS);
+
+ if (this->min_number_of_threads_ <= 0)
+ this->min_number_of_threads_ = 1;
+
+ value = JAWS_Options::instance ()->getenv ("JAWS_MAX_THYBRID_THREADS");
+ if (value != 0)
+ this->max_number_of_threads_ = ACE_OS::atoi (value);
+ else
+ this->max_number_of_threads_ =
+ ACE_OS::atoi (JAWS_DEFAULT_MAX_THYBRID_THREADS);
+
+ if (this->max_number_of_threads_ <= 0)
+ this->max_number_of_threads_ = -1;
+ else if (this->max_number_of_threads_ < this->min_number_of_threads_)
+ this->max_number_of_threads_ = this->min_number_of_threads_;
+
+ int r;
+ r = this->activate (THR_BOUND | THR_JOINABLE, this->min_number_of_threads_);
+ if (r < 0)
+ {
+ this->shutdown_task_ = 1;
+ this->error_ = 1;
+ }
+}
+
+int
+JAWS_THYBRID_Concurrency::putq (JAWS_Protocol_Handler *ph)
+{
+ if (this->error_)
+ return -1;
+
+ JAWS_CONCURRENCY_TASK *task = this;
+ int result = task->putq (& ph->mb_);
+
+ if (result != -1)
+ {
+ if (this->getting_ < this->min_number_of_threads_
+ && (this->max_number_of_threads_ < 0
+ || this->thr_count () < (size_t) this->max_number_of_threads_))
+ {
+ int r;
+ r = this->activate ( THR_BOUND | THR_JOINABLE
+ , 1 // number of threads
+ , 1 // force active
+ );
+ if (r < 0)
+ {
+ // ACE_ERROR
+ return -1;
+ }
+ }
+ }
+
+ return result;
+}
+
+int
+JAWS_THYBRID_Concurrency::getq (JAWS_Protocol_Handler *&ph)
+{
+ ph = 0;
+
+ JAWS_CONCURRENCY_TASK *task = this;
+
+ if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0)
+ return -1;
+
+ int getting = ++(this->getting_);
+
+ if (getting > this->min_number_of_threads_)
+ {
+ if (task->msg_queue ()->message_count () == 0)
+ {
+ --(this->getting_);
+ return -1;
+ }
+ }
+
+ ACE_Message_Block *mb = 0;
+ int result = task->getq (mb);
+
+ if (result != -1)
+ {
+ ph = (JAWS_Protocol_Handler *) mb->base ();
+
+ if (ph == 0)
+ {
+ // Shutdown this task;
+ this->shutdown_task_ = 1;
+ if (this->getting_ > 1)
+ {
+ task->putq (mb);
+ result = -1;
+ }
+
+ }
+ }
+
+ --(this->getting_);
+ return result;
+}
diff --git a/ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.h b/ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.h
new file mode 100644
index 00000000000..c75fbb1cb1f
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/THYBRID_Concurrency.h
@@ -0,0 +1,37 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_THYBRID_CONCURRENCY_H
+#define JAWS_THYBRID_CONCURRENCY_H
+
+#include "ace/Atomic_Op.h"
+
+#include "jaws3/Concurrency.h"
+
+class JAWS_Export JAWS_THYBRID_Concurrency : public JAWS_Concurrency_Impl
+{
+public:
+
+ JAWS_THYBRID_Concurrency (void);
+
+ int putq (JAWS_Protocol_Handler *ph);
+
+ int getq (JAWS_Protocol_Handler *&ph);
+
+ static JAWS_THYBRID_Concurrency * instance (void)
+ {
+ return ACE_Singleton<JAWS_THYBRID_Concurrency, ACE_SYNCH_MUTEX>
+ ::instance ();
+ }
+
+private:
+
+ ACE_Atomic_Op<ACE_SYNCH_MUTEX, int> getting_;
+ int min_number_of_threads_;
+ int max_number_of_threads_;
+ int shutdown_task_;
+ int error_;
+
+};
+
+#endif /* JAWS_THYBRID_CONCURRENCY_H */
diff --git a/ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.cpp b/ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.cpp
new file mode 100644
index 00000000000..4f91c5f34c8
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.cpp
@@ -0,0 +1,80 @@
+// $Id$
+
+#include "ace/OS_NS_stdlib.h"
+#include "ace/Message_Block.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/TPOOL_Concurrency.h"
+#include "jaws3/Protocol_Handler.h"
+#include "jaws3/Options.h"
+
+JAWS_TPOOL_Concurrency::JAWS_TPOOL_Concurrency (void)
+ : number_of_threads_ (5)
+ , shutdown_task_ (0)
+ , error_ (0)
+{
+ const char *value = JAWS_Options::instance ()->getenv ("JAWS_TPOOL_THREADS");
+ if (value != 0)
+ this->number_of_threads_ = ACE_OS::atoi (value);
+ else
+ this->number_of_threads_ = ACE_OS::atoi (JAWS_DEFAULT_TPOOL_THREADS);
+
+ if (this->number_of_threads_ <= 0)
+ this->number_of_threads_ = 5;
+
+ int r;
+ r = this->activate ( THR_BOUND | THR_JOINABLE, this->number_of_threads_);
+
+ if (r < 0)
+ {
+ // ACE_ERROR
+ this->error_ = 1;
+ this->shutdown_task_ = 1;
+ }
+}
+
+int
+JAWS_TPOOL_Concurrency::putq (JAWS_Protocol_Handler *ph)
+{
+ if (this->error_)
+ return -1;
+
+ JAWS_CONCURRENCY_TASK *task = this;
+ return task->putq (& ph->mb_);
+}
+
+int
+JAWS_TPOOL_Concurrency::getq (JAWS_Protocol_Handler *&ph)
+{
+ ph = 0;
+
+ JAWS_CONCURRENCY_TASK *task = this;
+
+ if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0)
+ return -1;
+
+ ACE_Message_Block *mb = 0;
+
+ int result = task->getq (mb);
+
+ if (result != -1)
+ {
+ ph = (JAWS_Protocol_Handler *) mb->base ();
+
+ if (ph == 0)
+ {
+ // Shutdown this task;
+ this->shutdown_task_ = 1;
+ if (this->number_of_threads_ && this->number_of_threads_-- > 1)
+ {
+ task->putq (mb);
+ result = -1;
+ }
+ }
+ }
+
+ return result;
+}
diff --git a/ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.h b/ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.h
new file mode 100644
index 00000000000..b9617b2fde3
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/TPOOL_Concurrency.h
@@ -0,0 +1,32 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_TPOOL_CONCURRENCY_H
+#define JAWS_TPOOL_CONCURRENCY_H
+
+#include "jaws3/Concurrency.h"
+
+class JAWS_Export JAWS_TPOOL_Concurrency : public JAWS_Concurrency_Impl
+{
+public:
+
+ JAWS_TPOOL_Concurrency (void);
+
+ int putq (JAWS_Protocol_Handler *ph);
+
+ int getq (JAWS_Protocol_Handler *&ph);
+
+ static JAWS_TPOOL_Concurrency * instance (void)
+ {
+ return ACE_Singleton<JAWS_TPOOL_Concurrency, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+private:
+
+ int number_of_threads_;
+ int shutdown_task_;
+ int error_;
+
+};
+
+#endif /* JAWS_TPOOL_CONCURRENCY_H */
diff --git a/ACE/apps/JAWS3/jaws3/TPR_Concurrency.cpp b/ACE/apps/JAWS3/jaws3/TPR_Concurrency.cpp
new file mode 100644
index 00000000000..6e15def5cb8
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/TPR_Concurrency.cpp
@@ -0,0 +1,89 @@
+// $Id$
+
+#include "ace/Message_Block.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Concurrency.h"
+#include "jaws3/TPR_Concurrency.h"
+#include "jaws3/Protocol_Handler.h"
+#include "jaws3/Options.h"
+
+
+JAWS_TPR_Concurrency::JAWS_TPR_Concurrency (void)
+ : getting_ (0)
+ , shutdown_task_ (0)
+ , error_ (0)
+{
+ int r;
+ r = this->activate (THR_BOUND | THR_JOINABLE);
+ if (r < 0)
+ {
+ this->error_ = 1;
+ this->shutdown_task_ = 1;
+ }
+}
+
+int
+JAWS_TPR_Concurrency::putq (JAWS_Protocol_Handler *ph)
+{
+ if (this->error_)
+ return -1;
+
+ JAWS_CONCURRENCY_TASK *task = this;
+ int result = task->putq (& ph->mb_);
+
+ if (result != -1)
+ {
+ int r;
+ r = this->activate ( THR_BOUND | THR_JOINABLE
+ , 1 // number of threads
+ , 1 // force active
+ );
+ if (r < 0)
+ {
+ // ACE_ERROR
+ return -1;
+ }
+ }
+
+ return result;
+}
+
+int
+JAWS_TPR_Concurrency::getq (JAWS_Protocol_Handler *&ph)
+{
+ ph = 0;
+
+ JAWS_CONCURRENCY_TASK *task = this;
+
+ if (this->shutdown_task_ && task->msg_queue ()->message_count () == 0)
+ return -1;
+
+ int getting = ++(this->getting_);
+
+ if (getting > 1 && task->msg_queue ()->message_count () == 0)
+ {
+ --(this->getting_);
+ return -1;
+ }
+
+ ACE_Message_Block *mb = 0;
+ int result = task->getq (mb);
+
+ if (result != -1)
+ {
+ ph = (JAWS_Protocol_Handler *) mb->base ();
+
+ if (ph == 0)
+ {
+ // Shutdown this task;
+ this->shutdown_task_ = 1;
+ }
+ }
+
+ --(this->getting_);
+ return result;
+}
diff --git a/ACE/apps/JAWS3/jaws3/TPR_Concurrency.h b/ACE/apps/JAWS3/jaws3/TPR_Concurrency.h
new file mode 100644
index 00000000000..9feff7da706
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/TPR_Concurrency.h
@@ -0,0 +1,35 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_TPR_CONCURRENCY_H
+#define JAWS_TPR_CONCURRENCY_H
+
+#include "ace/Atomic_Op.h"
+
+#include "jaws3/Concurrency.h"
+
+class JAWS_Export JAWS_TPR_Concurrency : public JAWS_Concurrency_Impl
+{
+public:
+
+ JAWS_TPR_Concurrency (void);
+
+ int putq (JAWS_Protocol_Handler *ph);
+
+ int getq (JAWS_Protocol_Handler *&ph);
+
+ static JAWS_TPR_Concurrency * instance (void)
+ {
+ return ACE_Singleton<JAWS_TPR_Concurrency, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+private:
+
+ ACE_Atomic_Op<ACE_SYNCH_MUTEX, int> getting_;
+ int min_number_of_threads_;
+ int shutdown_task_;
+ int error_;
+
+};
+
+#endif /* JAWS_TPR_CONCURRENCY_H */
diff --git a/ACE/apps/JAWS3/jaws3/Task_Timer.cpp b/ACE/apps/JAWS3/jaws3/Task_Timer.cpp
new file mode 100644
index 00000000000..a429a3fcf8e
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Task_Timer.cpp
@@ -0,0 +1,106 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "ace/OS_NS_sys_time.h"
+
+#include "jaws3/Task_Timer.h"
+#include "jaws3/Timer_Helpers.h"
+
+
+JAWS_Task_Timer::JAWS_Task_Timer (void)
+{
+ this->timer_queue_.activate ();
+}
+
+
+void
+JAWS_Task_Timer::schedule_timer ( long *timer_id
+ , const ACE_Time_Value &delta
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ JAWS_Timer_EH *eh = new JAWS_Timer_EH (completer, act);
+ if (eh == 0
+ || (*timer_id =
+ this->timer_queue_.schedule ( eh
+ , 0
+ , delta + ACE_OS::gettimeofday ()))
+ == -1)
+ {
+ JAWS_Event_Result timer_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TIMER_FAIL
+ );
+
+ if (completer)
+ completer->timer_complete (timer_result, act);
+
+ delete eh;
+ }
+}
+
+
+void
+JAWS_Task_Timer::schedule_absolute_timer ( long *timer_id
+ , const ACE_Time_Value &tv
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ JAWS_Timer_EH *eh = new JAWS_Timer_EH (completer, act);
+ if (eh == 0
+ || (*timer_id = this->timer_queue_.schedule (eh, 0, tv)) == -1)
+ {
+ JAWS_Event_Result timer_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TIMER_FAIL
+ );
+
+ if (completer)
+ completer->timer_complete (timer_result, act);
+
+ delete eh;
+ }
+}
+
+
+void
+JAWS_Task_Timer::schedule_interval_timer ( long *timer_id
+ , const ACE_Time_Value &interval
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ JAWS_Timer_EH *eh = new JAWS_Timer_EH (completer, act);
+ if (eh == 0
+ || (*timer_id =
+ this->timer_queue_.schedule ( eh
+ , 0
+ , interval + ACE_OS::gettimeofday ()
+ , interval
+ ))
+ == -1)
+ {
+ JAWS_Event_Result timer_result ( 0
+ , JAWS_Event_Result::JE_ERROR
+ , JAWS_Event_Result::JE_TIMER_FAIL
+ );
+
+ if (completer)
+ completer->timer_complete (timer_result, act);
+
+ delete eh;
+ }
+}
+
+
+void
+JAWS_Task_Timer::cancel_timer (long timer_id)
+{
+ this->timer_queue_.cancel (timer_id);
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Task_Timer.h b/ACE/apps/JAWS3/jaws3/Task_Timer.h
new file mode 100644
index 00000000000..a31781a922a
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Task_Timer.h
@@ -0,0 +1,56 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_TASK_TIMER_H
+#define JAWS_TASK_TIMER_H
+
+#include "ace/Singleton.h"
+#include "ace/Timer_Wheel.h"
+#include "ace/Timer_Queue_Adapters.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/Timer.h"
+
+class JAWS_Task_Timer;
+
+class JAWS_Export JAWS_Task_Timer : public JAWS_Timer_Impl
+{
+public:
+
+ JAWS_Task_Timer (void);
+
+ static JAWS_Timer_Impl * instance (void)
+ {
+ return ACE_Singleton<JAWS_Task_Timer, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ void schedule_timer ( long *timer_id
+ , const ACE_Time_Value &delta
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void schedule_absolute_timer ( long *timer_id
+ , const ACE_Time_Value &tv
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void schedule_interval_timer ( long *timer_id
+ , const ACE_Time_Value &interval
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void cancel_timer (long timer_id);
+ // NOTE: Cancelling the timer causes handle_close to be called, but
+ // not handle_timeout (of couse, I mean in the ACE_Event_Handler that
+ // is being used as the timer helper).
+
+private:
+
+ ACE_Thread_Timer_Queue_Adapter<ACE_Timer_Wheel> timer_queue_;
+
+};
+
+#endif /* JAWS_TASK_TIMER_H */
diff --git a/ACE/apps/JAWS3/jaws3/Templates.cpp b/ACE/apps/JAWS3/jaws3/Templates.cpp
new file mode 100644
index 00000000000..c28a9019318
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Templates.cpp
@@ -0,0 +1,72 @@
+// $Id$
+
+#include "ace/Reactor.h"
+#include "ace/Select_Reactor.h"
+#include "ace/Svc_Handler.h"
+#include "ace/SOCK_Stream.h"
+#include "ace/LSOCK_Stream.h"
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Asynch_IO.h"
+#include "jaws3/Concurrency.h"
+#include "jaws3/Export.h"
+#include "jaws3/IO.h"
+#include "jaws3/Event_Dispatcher.h"
+#include "jaws3/Event_Completer.h"
+#include "jaws3/Options.h"
+#include "jaws3/Protocol_Handler.h"
+#include "jaws3/Reactive_IO.h"
+#include "jaws3/Signal_Task.h"
+#include "jaws3/Symbol_Table.h"
+#include "jaws3/Synch_IO.h"
+#include "jaws3/TPOOL_Concurrency.h"
+#include "jaws3/TPR_Concurrency.h"
+#include "jaws3/THYBRID_Concurrency.h"
+#include "jaws3/Timer.h"
+#include "jaws3/Task_Timer.h"
+
+#define ACE_EHHTU_RW \
+ ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RW_MUTEX>
+#define ACE_EHHTU_R \
+ ACE_Event_Handler_Handle_Timeout_Upcall<ACE_SYNCH_RECURSIVE_MUTEX>
+
+#define ACE_WHEEL_TEMPLATE_ARGS_RW \
+ ACE_Event_Handler *, ACE_EHHTU_RW, ACE_SYNCH_RW_MUTEX
+#define ACE_WHEEL_TEMPLATE_ARGS_R \
+ ACE_Event_Handler *, ACE_EHHTU_R, ACE_SYNCH_RECURSIVE_MUTEX
+
+#define ACE_TWT_RW \
+ ACE_Timer_Wheel_T<ACE_WHEEL_TEMPLATE_ARGS_RW>
+#define ACE_TWT_R \
+ ACE_Timer_Wheel_T<ACE_WHEEL_TEMPLATE_ARGS_R>
+#define ACE_TWIT_RW \
+ ACE_Timer_Wheel_Iterator_T<ACE_WHEEL_TEMPLATE_ARGS_RW>
+#define ACE_TWIT_R \
+ ACE_Timer_Wheel_Iterator_T<ACE_WHEEL_TEMPLATE_ARGS_R>
+#define ACE_TQT_RW \
+ ACE_Timer_Queue_T<ACE_WHEEL_TEMPLATE_ARGS_RW>
+#define ACE_TQT_R \
+ ACE_Timer_Queue_T<ACE_WHEEL_TEMPLATE_ARGS_R>
+#define ACE_TQIT_RW \
+ ACE_Timer_Queue_Iterator_T<ACE_WHEEL_TEMPLATE_ARGS_RW>
+#define ACE_TQIT_R \
+ ACE_Timer_Queue_Iterator_T<ACE_WHEEL_TEMPLATE_ARGS_R>
+
+#if defined (ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION)
+template ACE_Singleton<ACE_Message_Block, ACE_Null_Mutex> *ACE_Singleton<ACE_Message_Block, ACE_Null_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Asynch_IO, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Asynch_IO, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Concurrency, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Concurrency, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_IO, ACE_Thread_Mutex> *ACE_Singleton<JAWS_IO, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Options, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Options, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Reactive_IO, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Reactive_IO, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Signal_Task, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Signal_Task, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Synch_IO, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Synch_IO, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_THYBRID_Concurrency, ACE_Thread_Mutex> *ACE_Singleton<JAWS_THYBRID_Concurrency, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_TPOOL_Concurrency, ACE_Thread_Mutex> *ACE_Singleton<JAWS_TPOOL_Concurrency, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_TPR_Concurrency, ACE_Thread_Mutex> *ACE_Singleton<JAWS_TPR_Concurrency, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Task_Timer, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Task_Timer, ACE_Thread_Mutex>::singleton_;
+template ACE_Singleton<JAWS_Timer, ACE_Thread_Mutex> *ACE_Singleton<JAWS_Timer, ACE_Thread_Mutex>::singleton_;
+#endif /* ACE_HAS_EXPLICIT_STATIC_TEMPLATE_MEMBER_INSTANTIATION */
diff --git a/ACE/apps/JAWS3/jaws3/Timer.cpp b/ACE/apps/JAWS3/jaws3/Timer.cpp
new file mode 100644
index 00000000000..33773520ddc
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Timer.cpp
@@ -0,0 +1,53 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Timer.h"
+#include "jaws3/Task_Timer.h"
+
+JAWS_Timer::JAWS_Timer (JAWS_Timer_Impl *impl)
+ : impl_ (impl)
+{
+ // TODO: Change this to use JAWS_Options after we have more than
+ // one way of handling timers.
+ if (this->impl_ == 0)
+ this->impl_ = JAWS_Task_Timer::instance ();
+}
+
+void
+JAWS_Timer::schedule_timer ( long *timer_id
+ , const ACE_Time_Value &delta
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->schedule_timer (timer_id, delta, completer, act);
+}
+
+void
+JAWS_Timer::schedule_absolute_timer ( long *timer_id
+ , const ACE_Time_Value &tv
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->schedule_absolute_timer (timer_id, tv, completer, act);
+}
+
+void
+JAWS_Timer::schedule_interval_timer ( long *timer_id
+ , const ACE_Time_Value &interval
+ , JAWS_Event_Completer *completer
+ , void *act
+ )
+{
+ this->impl_->schedule_interval_timer (timer_id, interval, completer, act);
+}
+
+void
+JAWS_Timer::cancel_timer (long timer_id)
+{
+ this->impl_->cancel_timer (timer_id);
+}
diff --git a/ACE/apps/JAWS3/jaws3/Timer.h b/ACE/apps/JAWS3/jaws3/Timer.h
new file mode 100644
index 00000000000..d2468344307
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Timer.h
@@ -0,0 +1,94 @@
+/* -*- c++ -*- */
+// $Id$
+
+#ifndef JAWS_TIMER_H
+#define JAWS_TIMER_H
+
+#include "ace/Singleton.h"
+#include "ace/Timer_Wheel.h"
+#include "ace/Timer_Queue_Adapters.h"
+
+#include "jaws3/Export.h"
+#include "jaws3/Event_Completer.h"
+
+class JAWS_Timer;
+class JAWS_Timer_Impl;
+
+class JAWS_Export JAWS_Timer_Impl
+// = TITLE
+// Implementation base class for Timers that corresponds to the
+// RHS of the Bridge pattern.
+{
+public:
+
+ virtual ~JAWS_Timer_Impl (void) {}
+
+ virtual void schedule_timer ( long *timer_id
+ , const ACE_Time_Value &delta
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+ // Schedule a timer to expire at now+delta.
+
+ virtual void schedule_absolute_timer ( long *timer_id
+ , const ACE_Time_Value &tv
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+ // Schedule a timer to expire at tv.
+
+ virtual void schedule_interval_timer ( long *timer_id
+ , const ACE_Time_Value &interval
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ ) = 0;
+ // Schedule a timer to expire at now+interval, and every interval following.
+
+ virtual void cancel_timer (long timer_id) = 0;
+ // Cancel a timer.
+
+};
+
+
+class JAWS_Export JAWS_Timer
+// = TITLE
+// Abstraction base class for Timers that corresponds to the LHS of the
+// Bridge pattern.
+{
+public:
+
+ JAWS_Timer (JAWS_Timer_Impl *impl = 0);
+
+ static JAWS_Timer * instance (void)
+ {
+ return ACE_Singleton<JAWS_Timer, ACE_SYNCH_MUTEX>::instance ();
+ }
+
+ void schedule_timer ( long *timer_id
+ , const ACE_Time_Value &delta
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void schedule_absolute_timer ( long *timer_id
+ , const ACE_Time_Value &tv
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void schedule_interval_timer ( long *timer_id
+ , const ACE_Time_Value &interval
+ , JAWS_Event_Completer *completer
+ , void *act = 0
+ );
+
+ void cancel_timer (long timer_id);
+
+private:
+
+ JAWS_Timer_Impl *impl_;
+
+};
+
+
+#endif /* JAWS_TIMER_H */
diff --git a/ACE/apps/JAWS3/jaws3/Timer_Helpers.cpp b/ACE/apps/JAWS3/jaws3/Timer_Helpers.cpp
new file mode 100644
index 00000000000..1b7d4b60c41
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Timer_Helpers.cpp
@@ -0,0 +1,40 @@
+// $Id$
+
+#ifndef JAWS_BUILD_DLL
+#define JAWS_BUILD_DLL
+#endif
+
+#include "jaws3/Timer_Helpers.h"
+
+int
+JAWS_Timer_EH::handle_timeout (const ACE_Time_Value &, const void *)
+{
+ JAWS_Event_Result timer_result ( 0
+ , JAWS_Event_Result::JE_OK
+ , JAWS_Event_Result::JE_TIMER_OK
+ );
+
+ if (this->completer_)
+ this->completer_->timer_complete (timer_result, this->act_);
+
+ if (this->interval_)
+ return 0;
+
+ this->expired_ = 1;
+ return -1;
+}
+
+int
+JAWS_Timer_EH::handle_close (ACE_HANDLE, ACE_Reactor_Mask)
+{
+ JAWS_Event_Result timer_result ( 0
+ , JAWS_Event_Result::JE_CANCEL
+ , JAWS_Event_Result::JE_TIMER_CANCEL
+ );
+
+ if (! this->expired_ && this->completer_)
+ this->completer_->timer_complete (timer_result, this->act_);
+
+ return 0;
+}
+
diff --git a/ACE/apps/JAWS3/jaws3/Timer_Helpers.h b/ACE/apps/JAWS3/jaws3/Timer_Helpers.h
new file mode 100644
index 00000000000..9ce8434975f
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/Timer_Helpers.h
@@ -0,0 +1,44 @@
+/* -*- c+ -*- */
+// $Id$
+
+#ifndef JAWS_TIMER_HELPERS_H
+#define JAWS_TIMER_HELPERS_H
+
+#include "ace/Singleton.h"
+#include "ace/Event_Handler.h"
+
+#include "jaws3/Timer.h"
+#include "jaws3/Event_Completer.h"
+#include "jaws3/Event_Result.h"
+
+class JAWS_Timer_EH : public ACE_Event_Handler
+{
+public:
+
+ JAWS_Timer_EH ( JAWS_Event_Completer *completer
+ , void *act = 0
+ , int interval = 0
+ )
+ : completer_ (completer)
+ , act_ (act)
+ , interval_ (interval)
+ , expired_ (0)
+ {
+ }
+
+ int handle_timeout (const ACE_Time_Value &tv, const void *act);
+ // Called when timer expires.
+
+ int handle_close (ACE_HANDLE h, ACE_Reactor_Mask m);
+ // Called directly when timer is canceled.
+
+private:
+
+ JAWS_Event_Completer *completer_;
+ void *act_;
+ const int interval_;
+ int expired_;
+
+};
+
+#endif /* JAWS_TIMER_HELPERS_H */
diff --git a/ACE/apps/JAWS3/jaws3/jaws.conf b/ACE/apps/JAWS3/jaws3/jaws.conf
new file mode 100644
index 00000000000..4f029ef4a44
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/jaws.conf
@@ -0,0 +1,15 @@
+# See jaws3/Options.h for default values
+#
+
+#JAWS_IO = SYNCH
+# SYNCH, ASYNCH, or REACTIVE
+
+#JAWS_CONCURRENCY = TPOOL
+# TPOOL, TPR, or THYBRID
+
+#JAWS_MIN_THYBRID_THREADS = 1
+
+#JAWS_MAX_THYBRID_THREADS = -1
+# -1 means no upper bound
+
+#JAWS_TPOOL_THREADS = 20
diff --git a/ACE/apps/JAWS3/jaws3/jaws3.mpc b/ACE/apps/JAWS3/jaws3/jaws3.mpc
new file mode 100644
index 00000000000..850c50b09c3
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/jaws3.mpc
@@ -0,0 +1,94 @@
+// -*- MPC -*-
+// $Id$
+
+project(JAWS3) : ace_output, acelib {
+ sharedname = JAWS3
+ dynamicflags = JAWS_BUILD_DLL
+ avoids += uses_wchar
+ avoids += ace_for_tao
+
+ specific(automake) {
+ includes += $(srcdir)/..
+ } else {
+ includes += ..
+ }
+
+ Source_Files {
+ Asynch_IO.cpp
+ Concurrency.cpp
+ Config_File.cpp
+ Datagram.cpp
+ Event_Completer.cpp
+ Event_Dispatcher.cpp
+ FILE.cpp
+ IO.cpp
+ Options.cpp
+ Protocol_Handler.cpp
+ Reactive_IO.cpp
+ Signal_Task.cpp
+ Symbol_Table.cpp
+ Synch_IO.cpp
+ THYBRID_Concurrency.cpp
+ TPOOL_Concurrency.cpp
+ TPR_Concurrency.cpp
+ Task_Timer.cpp
+ Templates.cpp
+ Timer.cpp
+ Timer_Helpers.cpp
+ }
+
+ Template_Files{
+ Cached_Allocator_T.cpp
+ Concurrency_T.cpp
+ }
+
+ Header_Files{
+ Asynch_IO.h
+ Asynch_IO_Helpers.h
+ Cached_Allocator_T.h
+ Concurrency.h
+ Concurrency_T.h
+ Config_File.h
+ Datagram.h
+ Event_Completer.h
+ Event_Dispatcher.h
+ Event_Result.h
+ Export.h
+ FILE.h
+ IO.h
+ Options.h
+ Protocol_Handler.h
+ Reactive_IO.h
+ Reactive_IO_Helpers.h
+ Signal_Task.h
+ Symbol_Table.h
+ Synch_IO.h
+ Task_Timer.h
+ THYBRID_Concurrency.h
+ Timer.h
+ Timer_Helpers.h
+ TPOOL_Concurrency.h
+ TPR_Concurrency.h
+ }
+
+ Inline_Files{
+ }
+}
+
+project(JAWS3_server) : aceexe {
+ avoids += uses_wchar
+ avoids += ace_for_tao
+
+ specific(automake) {
+ includes += $(srcdir)/..
+ } else {
+ includes += ..
+ }
+
+ exename = main
+ after += JAWS3
+ libs += JAWS3
+ Source_Files {
+ main.cpp
+ }
+}
diff --git a/ACE/apps/JAWS3/jaws3/main.cpp b/ACE/apps/JAWS3/jaws3/main.cpp
new file mode 100644
index 00000000000..a041a9822c1
--- /dev/null
+++ b/ACE/apps/JAWS3/jaws3/main.cpp
@@ -0,0 +1,33 @@
+// $Id$
+#include "ace/Log_Msg.h"
+#include "ace/Reactor.h"
+#include "ace/Select_Reactor.h"
+#include "ace/Service_Config.h"
+#include "ace/Thread_Manager.h"
+
+#include "jaws3/Event_Dispatcher.h"
+#include "jaws3/Signal_Task.h"
+
+int
+ACE_TMAIN(int argc, ACE_TCHAR *argv[])
+{
+ ACE_REACTOR_INSTANCE_INIT;
+
+ JAWS_Signal_Task::instance ();
+
+ if (ACE_Service_Config::open (argc, argv) == -1
+ && errno != ENOENT)
+ ACE_ERROR_RETURN ((LM_ERROR,
+ ACE_TEXT ("%p\n"),
+ ACE_TEXT ("open")),
+ 1);
+
+ // Run forever, performing the configured services until we
+ // shutdown.
+
+ JAWS_Event_Dispatcher::run_event_loop ();
+
+ ACE_Thread_Manager::instance ()->wait ();
+
+ return 0;
+}