diff options
author | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-01 08:40:32 +0000 |
---|---|---|
committer | schmidt <douglascraigschmidt@users.noreply.github.com> | 1996-11-01 08:40:32 +0000 |
commit | 76171efcb983b4f2ff55a4013fed794f7a9bb471 (patch) | |
tree | a817b83efdc199c8f292b9a5bfd4047ef900f6b0 /ace | |
parent | bad6c3a7b49b64377c60931084a6ef68ae64877b (diff) | |
download | ATCD-76171efcb983b4f2ff55a4013fed794f7a9bb471.tar.gz |
foo
Diffstat (limited to 'ace')
-rw-r--r-- | ace/Acceptor.cpp | 14 | ||||
-rw-r--r-- | ace/Malloc.h | 2 | ||||
-rw-r--r-- | ace/Malloc_T.h | 4 | ||||
-rw-r--r-- | ace/Module.cpp | 4 | ||||
-rw-r--r-- | ace/Module.h | 14 | ||||
-rw-r--r-- | ace/Module.i | 2 | ||||
-rw-r--r-- | ace/OS.h | 14 | ||||
-rw-r--r-- | ace/Reactor.cpp | 5 | ||||
-rw-r--r-- | ace/SString.cpp | 3 | ||||
-rw-r--r-- | ace/Service_Record.cpp | 8 | ||||
-rw-r--r-- | ace/Service_Repository.cpp | 2 | ||||
-rw-r--r-- | ace/Strategies.h | 10 | ||||
-rw-r--r-- | ace/Task.cpp | 90 | ||||
-rw-r--r-- | ace/Task.h | 117 | ||||
-rw-r--r-- | ace/Task.i | 97 | ||||
-rw-r--r-- | ace/Task_T.cpp | 98 | ||||
-rw-r--r-- | ace/Task_T.h | 130 | ||||
-rw-r--r-- | ace/Task_T.i | 98 | ||||
-rw-r--r-- | ace/Thread.h | 19 | ||||
-rw-r--r-- | ace/Thread.i | 26 | ||||
-rw-r--r-- | ace/Thread_Manager.cpp | 62 | ||||
-rw-r--r-- | ace/Thread_Manager.h | 68 | ||||
-rw-r--r-- | ace/Thread_Manager.i | 4 | ||||
-rw-r--r-- | ace/Token_Invariants.h | 6 | ||||
-rw-r--r-- | ace/config-win32-msvc4.0.h | 3 |
25 files changed, 422 insertions, 478 deletions
diff --git a/ace/Acceptor.cpp b/ace/Acceptor.cpp index f67c77115fe..a54aa8d69fa 100644 --- a/ace/Acceptor.cpp +++ b/ace/Acceptor.cpp @@ -456,12 +456,12 @@ ACE_Strategy_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Strategy_Acceptor (const char service_name[], const char service_description[]) : creation_strategy_ (0), - accept_strategy_ (0), - concurrency_strategy_ (0), - scheduling_strategy_ (0), delete_creation_strategy_ (0), + accept_strategy_ (0), delete_accept_strategy_ (0), + concurrency_strategy_ (0), delete_concurrency_strategy_ (0), + scheduling_strategy_ (0), delete_scheduling_strategy_ (0), service_name_ (0), service_description_ (0) @@ -674,8 +674,8 @@ ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::open template <class SVC_HANDLER, ACE_PEER_ACCEPTOR_1> ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor (void) - : delete_concurrency_strategy_ (0), - reactor_ (0) + : reactor_ (0), + delete_concurrency_strategy_ (0) { ACE_TRACE ("ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::ACE_Oneshot_Acceptor"); } @@ -716,8 +716,8 @@ ACE_Oneshot_Acceptor<SVC_HANDLER, ACE_PEER_ACCEPTOR_2>::handle_close (ACE_HANDLE // Note that if we aren't actually registered with the // ACE_Reactor then it's ok for this call to fail... - this->reactor_ && this->reactor_->remove_handler (this, - ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL); + this->reactor_ && this->reactor_->remove_handler + (this, ACE_Event_Handler::READ_MASK | ACE_Event_Handler::DONT_CALL); this->reactor_ = 0; diff --git a/ace/Malloc.h b/ace/Malloc.h index fe67fca2150..d5c73e99bba 100644 --- a/ace/Malloc.h +++ b/ace/Malloc.h @@ -210,7 +210,7 @@ struct ACE_Export ACE_Malloc_Stats #include "ace/Malloc.i" #endif /* __ACE_INLINE__ */ -// Include the ACE_Malloc templates and ACE_Memory_Pool stuff at this point. +// Include the ACE_Malloc templates and ACE_Memory_Pool classes at this point. #include "ace/Malloc_T.h" #include "ace/Memory_Pool.h" diff --git a/ace/Malloc_T.h b/ace/Malloc_T.h index 56998bf80f7..b5463c0671d 100644 --- a/ace/Malloc_T.h +++ b/ace/Malloc_T.h @@ -53,8 +53,8 @@ public: } // Constructor (this has to be inline to avoid bugs with some C++ compilers. - ~ACE_Allocator_Adapter (void); - // Destructor + virtual ~ACE_Allocator_Adapter (void); + // Destructor. // = Memory Management diff --git a/ace/Module.cpp b/ace/Module.cpp index 46f6ae1ea76..9471de5cc8e 100644 --- a/ace/Module.cpp +++ b/ace/Module.cpp @@ -50,7 +50,7 @@ ACE_Module<ACE_SYNCH_2>::link (ACE_Module<ACE_SYNCH_2> *m) } template <ACE_SYNCH_1> int -ACE_Module<ACE_SYNCH_2>::open (char *mod_name, +ACE_Module<ACE_SYNCH_2>::open (const char *mod_name, ACE_Task<ACE_SYNCH_2> *writer_q, ACE_Task<ACE_SYNCH_2> *reader_q, void *arg) @@ -114,7 +114,7 @@ ACE_Module<ACE_SYNCH_2>::~ACE_Module (void) } template <ACE_SYNCH_1> ACE_INLINE -ACE_Module<ACE_SYNCH_2>::ACE_Module (char *mod_name, +ACE_Module<ACE_SYNCH_2>::ACE_Module (const char *mod_name, ACE_Task<ACE_SYNCH_2> *writer_q, ACE_Task<ACE_SYNCH_2> *reader_q, void *flags) diff --git a/ace/Module.h b/ace/Module.h index b9983852a37..3f505121166 100644 --- a/ace/Module.h +++ b/ace/Module.h @@ -47,15 +47,17 @@ public: ACE_Module (void); // Create an empty Module. - ACE_Module (char *module_name, + ACE_Module (const char *module_name, ACE_Task<ACE_SYNCH_2> *writer = 0, - ACE_Task<ACE_SYNCH_2> *reader = 0, void *a = 0); + ACE_Task<ACE_SYNCH_2> *reader = 0, + void *a = 0); // Create an initialized module with <module_name> as its identity // and <reader> and <writer> as its tasks. - int open (char *module_name, - ACE_Task<ACE_SYNCH_2> *writer = 0, - ACE_Task<ACE_SYNCH_2> *reader = 0, void *a = 0); + int open (const char *module_name, + ACE_Task<ACE_SYNCH_2> *writer = 0, + ACE_Task<ACE_SYNCH_2> *reader = 0, + void *a = 0); // Create an initialized module with <module_name> as its identity // and <reader> and <writer> as its tasks. @@ -80,7 +82,7 @@ public: // = Identify the module const char *name (void) const; // Get the module name. - void name (char *); + void name (const char *); // Set the module name. // = Argument to the Tasks. diff --git a/ace/Module.i b/ace/Module.i index affc11f568c..8a2feaa7cde 100644 --- a/ace/Module.i +++ b/ace/Module.i @@ -25,7 +25,7 @@ ACE_Module<ACE_SYNCH_2>::name (void) const } template <ACE_SYNCH_1> ACE_INLINE void -ACE_Module<ACE_SYNCH_2>::name (char *n) +ACE_Module<ACE_SYNCH_2>::name (const char *n) { ACE_TRACE ("ACE_Module<ACE_SYNCH_2>::name"); ACE_OS::strncpy (this->name_, n, MAXNAMLEN); @@ -503,12 +503,7 @@ typedef struct } ACE_sema_t; #endif /* ACE_HAS_POSIX_SEM */ -#if defined (ACE_HAS_THREADS) -#if defined (ACE_HAS_STHREADS) -#include <synch.h> -#include <thread.h> -#endif /* ACE_HAS_STHREADS */ - +#if !defined (PTHREAD_CANCEL_ENABLE) struct cancel_state { int cancelstate; @@ -518,6 +513,13 @@ struct cancel_state int canceltype; // e.g., PTHREAD_CANCEL_DEFERRED and PTHREAD_CANCEL_ASYNCHRONOUS. }; +#endif /* PTHREAD_CANCEL_ENABLE */ + +#if defined (ACE_HAS_THREADS) +#if defined (ACE_HAS_STHREADS) +#include <synch.h> +#include <thread.h> +#endif /* ACE_HAS_STHREADS */ #if defined (ACE_HAS_DCETHREADS) || defined (ACE_HAS_PTHREADS) // Definitions for mapping POSIX pthreads onto Solaris threads. diff --git a/ace/Reactor.cpp b/ace/Reactor.cpp index 672caccc8f4..7dd6e141083 100644 --- a/ace/Reactor.cpp +++ b/ace/Reactor.cpp @@ -1552,7 +1552,10 @@ ACE_Reactor::handle_events (ACE_Time_Value *max_wait_time) // as a result of signals since they may be // time critical... - if (this->any_ready ()) + if (nfound == -1) + nfound = 0; + + if (this->any_ready ()) { nfound = this->fill_in_ready (rmask, wmask, emask); continue; diff --git a/ace/SString.cpp b/ace/SString.cpp index 77068413a12..ed9ca1da0a5 100644 --- a/ace/SString.cpp +++ b/ace/SString.cpp @@ -435,7 +435,8 @@ ACE_WString::ACE_WString (const char *s, // Constructor that actually copies memory. -ACE_WString::ACE_WString (const ACE_USHORT16 *s, ACE_Allocator *allocator) +ACE_WString::ACE_WString (const ACE_USHORT16 *s, + ACE_Allocator *allocator) : allocator_ (allocator) { ACE_TRACE ("ACE_WString::ACE_WString"); diff --git a/ace/Service_Record.cpp b/ace/Service_Record.cpp index b4b8dccbf65..63c7e5345c5 100644 --- a/ace/Service_Record.cpp +++ b/ace/Service_Record.cpp @@ -4,6 +4,9 @@ #define ACE_BUILD_DLL #include "ace/Service_Record.h" +#if !defined (ACE_SERVICE_RECORD_C) +#define ACE_SERVICE_RECORD_C + #if !defined (__ACE_INLINE__) #include "ace/Service_Record.i" #endif /* __ACE_INLINE__ */ @@ -332,9 +335,10 @@ template class ACE_Module<ACE_SYNCH>; template class ACE_Stream<ACE_SYNCH>; template class ACE_Task<ACE_SYNCH>; template class ACE_Message_Queue<ACE_SYNCH>; -template class ACE_Task_Exit<ACE_SYNCH>; -template class ACE_TSS<ACE_Task_Exit<ACE_SYNCH> >; +template class ACE_TSS<ACE_Task_Exit>; template class ACE_Thru_Task<ACE_SYNCH>; template class ACE_Stream_Head<ACE_SYNCH>; template class ACE_Stream_Tail<ACE_SYNCH>; #endif /* ACE_TEMPLATES_REQUIRE_SPECIALIZATION */ + +#endif /* ACE_SERVICE_RECORD_C */ diff --git a/ace/Service_Repository.cpp b/ace/Service_Repository.cpp index 8c5b91b40d7..9aece865ba2 100644 --- a/ace/Service_Repository.cpp +++ b/ace/Service_Repository.cpp @@ -218,7 +218,7 @@ ACE_Service_Repository::remove (const char name[]) if (handle != 0) ACE_OS::dlclose ((void *) handle); - if (--this->current_size_ > 1) + if (--this->current_size_ >= 1) this->service_vector_[i] = this->service_vector_[this->current_size_]; return 0; diff --git a/ace/Strategies.h b/ace/Strategies.h index 6506a0eb9c5..02129cca648 100644 --- a/ace/Strategies.h +++ b/ace/Strategies.h @@ -77,7 +77,7 @@ public: ACE_Thread_Manager * = 0); int open (SVC_HANDLER *, ACE_Thread_Manager * = 0); - ~ACE_Singleton_Strategy (void); + virtual ~ACE_Singleton_Strategy (void); // = Factory method. virtual SVC_HANDLER *make_svc_handler (void); @@ -206,7 +206,7 @@ public: int n_threads = 1); // Initialize the strategy. - ~ACE_Thread_Strategy (void); + virtual ~ACE_Thread_Strategy (void); // = Factory method. virtual int activate_svc_handler (SVC_HANDLER *svc_handler, @@ -259,7 +259,7 @@ public: virtual int open (int n_processes = 1); // Initialize the strategy. - ~ACE_Process_Strategy (void); + virtual ~ACE_Process_Strategy (void); // = Factory method. virtual int activate_svc_handler (SVC_HANDLER *svc_handler, @@ -311,7 +311,7 @@ public: virtual ACE_PEER_ACCEPTOR &acceptor (void) const; // Return a reference to the <peer_acceptor_>. - ~ACE_Accept_Strategy (void); + virtual ~ACE_Accept_Strategy (void); // = Factory method. virtual int accept_svc_handler (SVC_HANDLER *); @@ -346,7 +346,7 @@ public: ACE_Scheduling_Strategy (SVC_HANDLER * = 0); // Constructor - ~ACE_Scheduling_Strategy (void); + virtual ~ACE_Scheduling_Strategy (void); // Destructor // = Scheduling methods diff --git a/ace/Task.cpp b/ace/Task.cpp index 52fea1db94e..55be9be4754 100644 --- a/ace/Task.cpp +++ b/ace/Task.cpp @@ -1,9 +1,6 @@ // Task.cpp // $Id$ -#if !defined (ACE_TASK_C) -#define ACE_TASK_C - #define ACE_BUILD_DLL #include "ace/Task.h" #include "ace/Module.h" @@ -61,7 +58,7 @@ ACE_Task_Exit::ACE_Task_Exit (void) ACE_Task_Base * ACE_Task_Exit::get_task (void) { - ACE_TRACE ("ACE_Task_Exit<ACE_SYNCH_2>::get_task"); + ACE_TRACE ("ACE_Task_Exit::get_task"); return this->t_; } @@ -202,6 +199,9 @@ ACE_Task_Base::activate (long flags, // Keep the compiler from complaining. n_threads = n_threads; force_active = force_active; + priority = priority; + grp_id = grp_id; + task = task; flags = flags; errno = EINVAL; return -1; @@ -209,61 +209,6 @@ ACE_Task_Base::activate (long flags, #endif /* ACE_MT_SAFE */ } -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::dump (void) const -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::dump"); - ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); - ACE_DEBUG ((LM_DEBUG, "\nthr_mgr_ = %x", this->thr_mgr_)); - this->msg_queue_->dump (); - ACE_DEBUG ((LM_DEBUG, "delete_msg_queue_ = %d\n", this->delete_msg_queue_)); - ACE_DEBUG ((LM_DEBUG, "\nflags = %x", this->flags_)); - ACE_DEBUG ((LM_DEBUG, "\nmod_ = %x", this->mod_)); - ACE_DEBUG ((LM_DEBUG, "\nnext_ = %x", this->next_)); - ACE_DEBUG ((LM_DEBUG, "\ngrp_id_ = %d", this->grp_id_)); - ACE_DEBUG ((LM_DEBUG, "\nthr_count_ = %d", this->thr_count_)); -#if defined (ACE_MT_SAFE) - this->lock_.dump (); -#endif /* ACE_MT_SAFE */ - - ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); -} - -// If the user doesn't supply a ACE_Message_Queue pointer then we'll -// allocate one dynamically. Otherwise, we'll use the one they give. - -template<ACE_SYNCH_1> -ACE_Task<ACE_SYNCH_2>::ACE_Task (ACE_Thread_Manager *thr_man, - ACE_Message_Queue<ACE_SYNCH_2> *mq) - : ACE_Task_Base (thr_man), - msg_queue_ (0), - delete_msg_queue_ (0), - mod_ (0), - next_ (0) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ACE_Task"); - - if (mq == 0) - { - ACE_NEW (mq, ACE_Message_Queue<ACE_SYNCH_2>); - this->delete_msg_queue_ = 1; - } - - this->msg_queue_ = mq; -} - -template<ACE_SYNCH_1> -ACE_Task<ACE_SYNCH_2>::~ACE_Task (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::~ACE_Task"); - if (this->delete_msg_queue_) - delete this->msg_queue_; - - // These assignments aren't strickly necessary but they help guard - // against odd race conditions... - this->delete_msg_queue_ = 0; -} - // Note that this routine often does not return since the thread that // is executing it will do an ACE_Thread::exit() first! @@ -285,31 +230,4 @@ ACE_Task_Base::svc_run (ACE_Task_Base *t) /* NOTREACHED */ } -template<ACE_SYNCH_1> ACE_Task<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::sibling (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::sibling"); - if (this->mod_ == 0) - return 0; - else - return this->mod_->sibling (this); -} - -template<ACE_SYNCH_1> const char * -ACE_Task<ACE_SYNCH_2>::name (void) const -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::name"); - if (this->mod_ == 0) - return 0; - else - return this->mod_->name (); -} - -template<ACE_SYNCH_1> ACE_Module<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::module (void) const -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::module"); - return this->mod_; -} -#endif /* ACE_TASK_C */ diff --git a/ace/Task.h b/ace/Task.h index e608ee4471b..bc254fa481f 100644 --- a/ace/Task.h +++ b/ace/Task.h @@ -1,7 +1,6 @@ /* -*- C++ -*- */ // $Id$ - // ============================================================================ // // = LIBRARY @@ -19,12 +18,7 @@ #define ACE_TASK_H #include "ace/Service_Object.h" -#include "ace/Message_Queue.h" #include "ace/Thread_Manager.h" -#include "ace/Synch_T.h" - -// Forward decls... -template <ACE_SYNCH_1> class ACE_Module; class ACE_Task_Flags // = TITLE @@ -111,10 +105,6 @@ public: void thr_mgr (ACE_Thread_Manager *); // Set the thread manager associated with this Task. - size_t thr_count (void); - // Returns the number of threads currently running within a task. - // If we're a passive object this value is 0, else it's > 0. - static void *svc_run (ACE_Task_Base *); // Routine that runs the service routine as a daemon thread. @@ -124,6 +114,10 @@ public: int is_writer (void); // True if queue is a writer, else false. + size_t thr_count (void); + // Returns the number of threads currently running within a task. + // If we're a passive object this value is 0, else it's > 0. + void thr_count_dec (void); // Atomically decrement the thread count by 1. This should only be // called by the <ACE_Task_Exit> class destructor. @@ -153,100 +147,6 @@ public: #endif /* ACE_MT_SAFE */ }; -template <ACE_SYNCH_1> -class ACE_Task : public ACE_Task_Base - // = TITLE - // Primary interface for application message processing, as well - // as input and output message queueing. - // - // = DESCRIPTION - // This class serves as the basis for passive and active objects - // in ACE. -{ -friend class ACE_Module<ACE_SYNCH_2>; -friend class ACE_Module_Type; -public: - // = Initialization/termination methods. - ACE_Task (ACE_Thread_Manager *thr_mgr = 0, - ACE_Message_Queue<ACE_SYNCH_2> *mq = 0); - // Initialize a Task, supplying a thread manager and a message - // queue. If the user doesn't supply a ACE_Message_Queue pointer - // then we'll allocate one dynamically. Otherwise, we'll use the - // one they give. - - virtual ~ACE_Task (void); - // Destructor. - - ACE_Message_Queue<ACE_SYNCH_2> *msg_queue (void); - // Gets the message queue associated with this task. - - void msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *); - // Sets the message queue associated with this task. - -public: // Should be protected: - // = Message queue manipulation methods. - - int putq (ACE_Message_Block *, ACE_Time_Value *tv = 0); - // Insert message into the message list. - - int getq (ACE_Message_Block *&mb, ACE_Time_Value *tv = 0); - // Extract the first message from the list (blocking). - - int ungetq (ACE_Message_Block *, ACE_Time_Value *tv = 0); - // Return a message to the queue. - - int can_put (ACE_Message_Block *); - // Tests whether we can enqueue a message without blocking. - - int reply (ACE_Message_Block *, ACE_Time_Value *tv = 0); - // Turn the message back around. - - int put_next (ACE_Message_Block *msg, ACE_Time_Value *tv = 0); - // Transfer message to the adjacent ACE_Task in a ACE_Stream. - - // = ACE_Task utility routines to identify names et al. - const char *name (void) const; - // Return the name of the enclosing Module if there's one associated - // with the Task, else returns 0. - - // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). - ACE_Task<ACE_SYNCH_2> *next (void); - // Get next Task pointer. - void next (ACE_Task<ACE_SYNCH_2> *); - // Set next Task pointer. - - ACE_Task<ACE_SYNCH_2> *sibling (void); - // Return the Task's sibling if there's one associated with the - // Task's Module, else returns 0. - - ACE_Module<ACE_SYNCH_2> *module (void) const; - // Return the Task's Module if there is one, else returns 0. - - int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL); /* Flush the queue */ - // Special routines corresponding to certain message types. - - void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t); - // Manipulate watermarks. - - ACE_Message_Queue<ACE_SYNCH_2> *msg_queue_; - // List of messages on the ACE_Task.. - - int delete_msg_queue_; - // 1 if should delete Message_Queue, 0 otherwise. - - ACE_Module<ACE_SYNCH_2> *mod_; - // Back-pointer to the enclosing module. - - ACE_Task<ACE_SYNCH_2> *next_; - // Pointer to adjacent ACE_Task. - - void dump (void) const; - // Dump the state of an object. - - ACE_ALLOC_HOOK_DECLARE; - // Declare the dynamic allocation hooks. -}; - class ACE_Task_Exit // = TITLE // Keep exit information for a Task in thread specific storage so @@ -303,12 +203,7 @@ private: #include "ace/Task.i" #endif /* __ACE_INLINE__ */ -#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) -#include "ace/Task.cpp" -#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ - -#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) -#pragma implementation ("Task.cpp") -#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ +// Include the ACE_Task templates classes at this point. +#include "ace/Task_T.h" #endif /* ACE_TASK_H */ diff --git a/ace/Task.i b/ace/Task.i index 51d223d85be..e5bf79b480a 100644 --- a/ace/Task.i +++ b/ace/Task.i @@ -56,104 +56,9 @@ ACE_Task_Base::is_writer (void) // Default ACE_Task service routine -int +ACE_INLINE int ACE_Task_Base::svc (void) { ACE_TRACE ("ACE_Task_Base::svc"); return 0; } - -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, - size_t size) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::water_marks"); - if (cmd == ACE_IO_Cntl_Msg::SET_LWM) - this->msg_queue_->low_water_mark (size); - else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ - this->msg_queue_->high_water_mark (size); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::getq"); - return this->msg_queue_->dequeue_head (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::can_put (ACE_Message_Block *) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::can_put"); - assert (!"not implemented"); - return -1; -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::putq"); - return this->msg_queue_->enqueue_tail (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ungetq"); - return this->msg_queue_->enqueue_head (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::flush (u_long flag) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::flush"); - if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) - return this->msg_queue_ != 0 && this->msg_queue_->close (); - else - return -1; // Note, need to be more careful about what we free... -} - -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *mq) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); - this->msg_queue_ = mq; -} - -template <ACE_SYNCH_1> ACE_Message_Queue<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::msg_queue (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); - return this->msg_queue_; -} - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::reply"); - return this->sibling ()->put_next (mb, tv); -} - -template <ACE_SYNCH_1> ACE_INLINE ACE_Task<ACE_SYNCH_2> * -ACE_Task<ACE_SYNCH_2>::next (void) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); - return this->next_; -} - -template <ACE_SYNCH_1> ACE_INLINE void -ACE_Task<ACE_SYNCH_2>::next (ACE_Task<ACE_SYNCH_2> *q) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); - this->next_ = q; -} - -// Transfer msg to the next ACE_Task. - -template <ACE_SYNCH_1> ACE_INLINE int -ACE_Task<ACE_SYNCH_2>::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) -{ - ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::put_next"); - return this->next_ == 0 ? -1 : this->next_->put (msg, tv); -} - diff --git a/ace/Task_T.cpp b/ace/Task_T.cpp new file mode 100644 index 00000000000..a31045142a6 --- /dev/null +++ b/ace/Task_T.cpp @@ -0,0 +1,98 @@ +// Task.cpp +// $Id$ + +#if !defined (ACE_TASK_T_C) +#define ACE_TASK_T_C + +#define ACE_BUILD_DLL +#include "ace/Task_T.h" +#include "ace/Module.h" +#include "ace/Service_Config.h" + +#if !defined (__ACE_INLINE__) +#include "ace/Task_T.i" +#endif /* __ACE_INLINE__ */ + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::dump (void) const +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::dump"); + ACE_DEBUG ((LM_DEBUG, ACE_BEGIN_DUMP, this)); + ACE_DEBUG ((LM_DEBUG, "\nthr_mgr_ = %x", this->thr_mgr_)); + this->msg_queue_->dump (); + ACE_DEBUG ((LM_DEBUG, "delete_msg_queue_ = %d\n", this->delete_msg_queue_)); + ACE_DEBUG ((LM_DEBUG, "\nflags = %x", this->flags_)); + ACE_DEBUG ((LM_DEBUG, "\nmod_ = %x", this->mod_)); + ACE_DEBUG ((LM_DEBUG, "\nnext_ = %x", this->next_)); + ACE_DEBUG ((LM_DEBUG, "\ngrp_id_ = %d", this->grp_id_)); + ACE_DEBUG ((LM_DEBUG, "\nthr_count_ = %d", this->thr_count_)); +#if defined (ACE_MT_SAFE) + this->lock_.dump (); +#endif /* ACE_MT_SAFE */ + + ACE_DEBUG ((LM_DEBUG, ACE_END_DUMP)); +} + +// If the user doesn't supply a ACE_Message_Queue pointer then we'll +// allocate one dynamically. Otherwise, we'll use the one they give. + +template<ACE_SYNCH_1> +ACE_Task<ACE_SYNCH_2>::ACE_Task (ACE_Thread_Manager *thr_man, + ACE_Message_Queue<ACE_SYNCH_2> *mq) + : ACE_Task_Base (thr_man), + msg_queue_ (0), + delete_msg_queue_ (0), + mod_ (0), + next_ (0) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ACE_Task"); + + if (mq == 0) + { + ACE_NEW (mq, ACE_Message_Queue<ACE_SYNCH_2>); + this->delete_msg_queue_ = 1; + } + + this->msg_queue_ = mq; +} + +template<ACE_SYNCH_1> +ACE_Task<ACE_SYNCH_2>::~ACE_Task (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::~ACE_Task"); + if (this->delete_msg_queue_) + delete this->msg_queue_; + + // These assignments aren't strickly necessary but they help guard + // against odd race conditions... + this->delete_msg_queue_ = 0; +} + +template<ACE_SYNCH_1> ACE_Task<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::sibling (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::sibling"); + if (this->mod_ == 0) + return 0; + else + return this->mod_->sibling (this); +} + +template<ACE_SYNCH_1> const char * +ACE_Task<ACE_SYNCH_2>::name (void) const +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::name"); + if (this->mod_ == 0) + return 0; + else + return this->mod_->name (); +} + +template<ACE_SYNCH_1> ACE_Module<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::module (void) const +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::module"); + return this->mod_; +} + +#endif /* ACE_TASK_T_C */ diff --git a/ace/Task_T.h b/ace/Task_T.h new file mode 100644 index 00000000000..e65f2e9b979 --- /dev/null +++ b/ace/Task_T.h @@ -0,0 +1,130 @@ +// ============================================================================ +// +// = LIBRARY +// ace +// +// = FILENAME +// Task_T.h +// +// = AUTHOR +// Doug Schmidt +// +// ============================================================================ + +#if !defined (ACE_TASK_T_H) +#define ACE_TASK_T_H + +#include "ace/Message_Queue.h" +#include "ace/Synch_T.h" +#include "ace/Task.h" + +// Forward decls... +template <ACE_SYNCH_1> class ACE_Module; + +template <ACE_SYNCH_1> +class ACE_Task : public ACE_Task_Base + // = TITLE + // Primary interface for application message processing, as well + // as input and output message queueing. + // + // = DESCRIPTION + // This class serves as the basis for passive and active objects + // in ACE. +{ +friend class ACE_Module<ACE_SYNCH_2>; +friend class ACE_Module_Type; +public: + // = Initialization/termination methods. + ACE_Task (ACE_Thread_Manager *thr_mgr = 0, + ACE_Message_Queue<ACE_SYNCH_2> *mq = 0); + // Initialize a Task, supplying a thread manager and a message + // queue. If the user doesn't supply a ACE_Message_Queue pointer + // then we'll allocate one dynamically. Otherwise, we'll use the + // one they give. + + virtual ~ACE_Task (void); + // Destructor. + + ACE_Message_Queue<ACE_SYNCH_2> *msg_queue (void); + // Gets the message queue associated with this task. + + void msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *); + // Sets the message queue associated with this task. + +public: // Should be protected: + // = Message queue manipulation methods. + + int putq (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Insert message into the message list. + + int getq (ACE_Message_Block *&mb, ACE_Time_Value *tv = 0); + // Extract the first message from the list (blocking). + + int ungetq (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Return a message to the queue. + + int can_put (ACE_Message_Block *); + // Tests whether we can enqueue a message without blocking. + + int reply (ACE_Message_Block *, ACE_Time_Value *tv = 0); + // Turn the message back around. + + int put_next (ACE_Message_Block *msg, ACE_Time_Value *tv = 0); + // Transfer message to the adjacent ACE_Task in a ACE_Stream. + + // = ACE_Task utility routines to identify names et al. + const char *name (void) const; + // Return the name of the enclosing Module if there's one associated + // with the Task, else returns 0. + + // = Pointers to next ACE_Task_Base (if ACE is part of an ACE_Stream). + ACE_Task<ACE_SYNCH_2> *next (void); + // Get next Task pointer. + void next (ACE_Task<ACE_SYNCH_2> *); + // Set next Task pointer. + + ACE_Task<ACE_SYNCH_2> *sibling (void); + // Return the Task's sibling if there's one associated with the + // Task's Module, else returns 0. + + ACE_Module<ACE_SYNCH_2> *module (void) const; + // Return the Task's Module if there is one, else returns 0. + + int flush (u_long flag = ACE_Task_Flags::ACE_FLUSHALL); /* Flush the queue */ + // Special routines corresponding to certain message types. + + void water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds, size_t); + // Manipulate watermarks. + + ACE_Message_Queue<ACE_SYNCH_2> *msg_queue_; + // List of messages on the ACE_Task.. + + int delete_msg_queue_; + // 1 if should delete Message_Queue, 0 otherwise. + + ACE_Module<ACE_SYNCH_2> *mod_; + // Back-pointer to the enclosing module. + + ACE_Task<ACE_SYNCH_2> *next_; + // Pointer to adjacent ACE_Task. + + void dump (void) const; + // Dump the state of an object. + + ACE_ALLOC_HOOK_DECLARE; + // Declare the dynamic allocation hooks. +}; + +#if defined (__ACE_INLINE__) +#include "ace/Task_T.i" +#endif /* __ACE_INLINE__ */ + +#if defined (ACE_TEMPLATES_REQUIRE_SOURCE) +#include "ace/Task_T.cpp" +#endif /* ACE_TEMPLATES_REQUIRE_SOURCE */ + +#if defined (ACE_TEMPLATES_REQUIRE_PRAGMA) +#pragma implementation ("Task_T.cpp") +#endif /* ACE_TEMPLATES_REQUIRE_PRAGMA */ + +#endif /* ACE_TASK_T_H */ diff --git a/ace/Task_T.i b/ace/Task_T.i new file mode 100644 index 00000000000..9f5ba06054e --- /dev/null +++ b/ace/Task_T.i @@ -0,0 +1,98 @@ +/* -*- C++ -*- */ +// $Id$ + +// Task_T.i + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::water_marks (ACE_IO_Cntl_Msg::ACE_IO_Cntl_Cmds cmd, + size_t size) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::water_marks"); + if (cmd == ACE_IO_Cntl_Msg::SET_LWM) + this->msg_queue_->low_water_mark (size); + else /* cmd == ACE_IO_Cntl_Msg::SET_HWM */ + this->msg_queue_->high_water_mark (size); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::getq (ACE_Message_Block *&mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::getq"); + return this->msg_queue_->dequeue_head (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::can_put (ACE_Message_Block *) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::can_put"); + assert (!"not implemented"); + return -1; +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::putq (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::putq"); + return this->msg_queue_->enqueue_tail (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::ungetq (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::ungetq"); + return this->msg_queue_->enqueue_head (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::flush (u_long flag) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::flush"); + if (ACE_BIT_ENABLED (flag, ACE_Task_Flags::ACE_FLUSHALL)) + return this->msg_queue_ != 0 && this->msg_queue_->close (); + else + return -1; // Note, need to be more careful about what we free... +} + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::msg_queue (ACE_Message_Queue<ACE_SYNCH_2> *mq) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); + this->msg_queue_ = mq; +} + +template <ACE_SYNCH_1> ACE_Message_Queue<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::msg_queue (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::msg_queue"); + return this->msg_queue_; +} + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::reply (ACE_Message_Block *mb, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::reply"); + return this->sibling ()->put_next (mb, tv); +} + +template <ACE_SYNCH_1> ACE_INLINE ACE_Task<ACE_SYNCH_2> * +ACE_Task<ACE_SYNCH_2>::next (void) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); + return this->next_; +} + +template <ACE_SYNCH_1> ACE_INLINE void +ACE_Task<ACE_SYNCH_2>::next (ACE_Task<ACE_SYNCH_2> *q) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::next"); + this->next_ = q; +} + +// Transfer msg to the next ACE_Task. + +template <ACE_SYNCH_1> ACE_INLINE int +ACE_Task<ACE_SYNCH_2>::put_next (ACE_Message_Block *msg, ACE_Time_Value *tv) +{ + ACE_TRACE ("ACE_Task<ACE_SYNCH_2>::put_next"); + return this->next_ == 0 ? -1 : this->next_->put (msg, tv); +} diff --git a/ace/Thread.h b/ace/Thread.h index 0d90998570b..9258f4093e3 100644 --- a/ace/Thread.h +++ b/ace/Thread.h @@ -20,24 +20,6 @@ #include "ace/ACE.h" -#if !defined (ACE_HAS_THREADS) -class ACE_Export ACE_Thread -{ -public: - static ACE_thread_t self (void); - // Return the unique ID of the thread. - - static void self (ACE_hthread_t &t_id); - // Return the unique kernel ID of the thread. - - static void exit (void *status = 0); - // Exit the current thread and return "status". - -private: - ACE_Thread (void); - // Ensure that we don't get instantiated. -}; -#else class ACE_Export ACE_Thread { // = TITLE @@ -175,7 +157,6 @@ private: ACE_Thread (void); // Ensure that we don't get instantiated. }; -#endif /* ACE_HAS_THREADS */ #if defined (__ACE_INLINE__) #include "ace/Thread.i" diff --git a/ace/Thread.i b/ace/Thread.i index c2842516a02..7d648b9207c 100644 --- a/ace/Thread.i +++ b/ace/Thread.i @@ -3,30 +3,6 @@ // Thread.i -#if !defined (ACE_HAS_THREADS) - -ACE_INLINE ACE_thread_t -ACE_Thread::self (void) -{ -// ACE_TRACE ("ACE_Thread::self"); - return ACE_OS::thr_self (); -} - -ACE_INLINE void -ACE_Thread::self (ACE_hthread_t &t_id) -{ -// ACE_TRACE ("ACE_Thread::self"); - ACE_OS::thr_self (t_id); -} - -ACE_INLINE void -ACE_Thread::exit (void *status) -{ - ACE_TRACE ("ACE_Thread::exit"); - ACE_OS::exit (*((int *) status)); -} -#else - // Allocates a <keyp> that is used to identify data that is specific // to each thread in the process. The key is global to all threads in // the process. @@ -262,5 +238,3 @@ ACE_Thread::self (ACE_hthread_t &t_id) // ACE_TRACE ("ACE_Thread::self"); ACE_OS::thr_self (t_id); } - -#endif /* !defined (ACE_HAS_THREADS) */ diff --git a/ace/Thread_Manager.cpp b/ace/Thread_Manager.cpp index c69df42ed22..035af3bf0ec 100644 --- a/ace/Thread_Manager.cpp +++ b/ace/Thread_Manager.cpp @@ -11,8 +11,6 @@ ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Control) ACE_ALLOC_HOOK_DEFINE(ACE_Thread_Manager) -#if defined (ACE_HAS_THREADS) - void ACE_Thread_Manager::dump (void) const { @@ -50,7 +48,7 @@ ACE_Thread_Manager::thread_descriptor (ACE_thread_t thr_id, ACE_Thread_Descriptor &descriptor) { ACE_TRACE ("ACE_Thread_Descriptor::thread_descriptor"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); return this->thread_descriptor_i (thr_id, descriptor); } @@ -78,7 +76,7 @@ ACE_Thread_Manager::hthread_descriptor (ACE_hthread_t thr_handle, ACE_Thread_Descriptor &descriptor) { ACE_TRACE ("ACE_Thread_Descriptor::hthread_descriptor"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); return this->hthread_descriptor_i (thr_handle, descriptor); } @@ -89,7 +87,7 @@ int ACE_Thread_Manager::thr_self (ACE_hthread_t &self) { ACE_TRACE ("ACE_Thread_Descriptor::thr_self"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); // Try to get the cached HANDLE out of TSS to avoid lookup. ACE_hthread_t *handle = ACE_LOG_MSG->thr_handle (); @@ -138,7 +136,7 @@ int ACE_Thread_Manager::open (size_t size) { ACE_TRACE ("ACE_Thread_Manager::open"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); if (this->max_table_size_ < size) this->resize (size); @@ -151,8 +149,10 @@ ACE_Thread_Manager::ACE_Thread_Manager (size_t size) : thr_table_ (0), max_table_size_ (0), current_count_ (0), - grp_id_ (1), - zero_cond_ (lock_) + grp_id_ (1) +#if defined (ACE_HAS_THREADS) + , zero_cond_ (lock_) +#endif /* ACE_HAS_THREADS */ { ACE_TRACE ("ACE_Thread_Manager::ACE_Thread_Manager"); if (this->open (size) == -1) @@ -235,7 +235,7 @@ ACE_Thread_Manager::spawn (ACE_THR_FUNC func, size_t stack_size) { ACE_TRACE ("ACE_Thread_Manager::spawn"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); if (grp_id == -1) grp_id = this->grp_id_++; // Increment the group id. @@ -259,7 +259,7 @@ ACE_Thread_Manager::spawn_n (int n, ACE_Task_Base *task) { ACE_TRACE ("ACE_Thread_Manager::spawn_n"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); if (grp_id == -1) grp_id = this->grp_id_++; // Increment the group id. @@ -317,7 +317,7 @@ ACE_Thread_Manager::insert_thr (ACE_thread_t t_id, int grp_id) { ACE_TRACE ("ACE_Thread_Manager::insert_thr"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); // Check for duplicates and bail out if they're already // registered... @@ -347,9 +347,11 @@ ACE_Thread_Manager::remove_thr (int i) this->current_count_--; +#if defined (ACE_HAS_THREADS) // Tell all waiters when there are no more threads left in the pool. if (this->current_count_ == 0) this->zero_cond_.broadcast (); +#endif /* ACE_HAS_THREADS */ } // Factory out some common behavior to simplify the following methods. @@ -423,7 +425,7 @@ ACE_Thread_Manager::find (ACE_thread_t t_id) } #define ACE_EXECUTE_OP(OP) \ - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); \ + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); \ int i = this->find (t_id); \ if (i == -1) return -1; \ return OP (i); @@ -469,7 +471,7 @@ ACE_Thread_Manager::check_state (ACE_Thread_State state, ACE_thread_t id) { ACE_TRACE ("ACE_Thread_Manager::check_state"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_Thread_State *thr_state = 0; #if 0 @@ -537,7 +539,7 @@ int ACE_Thread_Manager::get_grp (ACE_thread_t t_id, int &grp_id) { ACE_TRACE ("ACE_Thread_Manager::get_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int i = this->find (t_id); if (i == -1) @@ -552,7 +554,7 @@ int ACE_Thread_Manager::set_grp (ACE_thread_t t_id, int grp_id) { ACE_TRACE ("ACE_Thread_Manager::set_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int i = this->find (t_id); if (i == -1) @@ -569,7 +571,7 @@ ACE_Thread_Manager::apply_grp (int grp_id, int arg) { ACE_TRACE ("ACE_Thread_Manager::apply_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int result = 0; @@ -623,7 +625,7 @@ int ACE_Thread_Manager::apply_all (THR_FUNC func, int arg) { ACE_TRACE ("ACE_Thread_Manager::apply_all"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int result = 0; @@ -671,7 +673,7 @@ void * ACE_Thread_Manager::exit (void *status, int do_thr_exit) { ACE_TRACE ("ACE_Thread_Manager::exit"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, 0)); int i = this->find (ACE_Thread::self ()); @@ -703,11 +705,15 @@ int ACE_Thread_Manager::wait (const ACE_Time_Value *timeout) { ACE_TRACE ("ACE_Thread_Manager::wait"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); +#if defined (ACE_HAS_THREADS) while (this->current_count_ > 0) if (this->zero_cond_.wait (timeout) == -1) return -1; +#else + timeout = timeout; +#endif /* ACE_HAS_THREADS */ return 0; } @@ -749,7 +755,7 @@ ACE_Thread_Manager::apply_task (ACE_Task_Base *task, int arg) { ACE_TRACE ("ACE_Thread_Manager::apply_task"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int result = 0; @@ -823,7 +829,7 @@ int ACE_Thread_Manager::num_tasks_in_group (int grp_id) { ACE_TRACE ("ACE_Thread_Manager::num_tasks_in_group"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int tasks_count = 0; @@ -841,7 +847,7 @@ int ACE_Thread_Manager::num_threads_in_task (ACE_Task_Base *task) { ACE_TRACE ("ACE_Thread_Manager::num_threads_in_task"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int threads_count = 0; @@ -860,7 +866,7 @@ ACE_Thread_Manager::task_list (int grp_id, size_t n) { ACE_TRACE ("ACE_Thread_Manager::task_list"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_Task_Base **task_list_iterator = task_list; size_t task_list_count = 0; @@ -885,7 +891,7 @@ ACE_Thread_Manager::thread_list (ACE_Task_Base *task, size_t n) { ACE_TRACE ("ACE_Thread_Manager::thread_list"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_thread_t *thread_list_iterator = thread_list; size_t thread_list_count = 0; @@ -908,7 +914,7 @@ ACE_Thread_Manager::hthread_list (ACE_Task_Base *task, size_t n) { ACE_TRACE ("ACE_Thread_Manager::thread_list"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); ACE_hthread_t *hthread_list_iterator = hthread_list; size_t hthread_list_count = 0; @@ -930,7 +936,7 @@ ACE_Thread_Manager::set_grp (ACE_Task_Base *task, int grp_id) { ACE_TRACE ("ACE_Thread_Manager::set_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); for (size_t i = 0; i < this->current_count_; i++) if (this->thr_table_[i].task_ == task) @@ -943,7 +949,7 @@ ACE_Thread_Manager::get_grp (ACE_Task_Base *task, int &grp_id) { ACE_TRACE ("ACE_Thread_Manager::get_grp"); - ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1); + ACE_MT (ACE_GUARD_RETURN (ACE_Thread_Mutex, ace_mon, this->lock_, -1)); int i = this->find_task (task); @@ -1010,5 +1016,3 @@ ACE_Thread_Control::exit (void *exit_status) return 0; } } - -#endif /* !defined (ACE_HAS_THREADS) */ diff --git a/ace/Thread_Manager.h b/ace/Thread_Manager.h index a4f9a623c71..e092a477135 100644 --- a/ace/Thread_Manager.h +++ b/ace/Thread_Manager.h @@ -67,71 +67,6 @@ private: // Current state of the thread. }; -#if !defined (ACE_HAS_THREADS) - -class ACE_Export ACE_Thread_Manager -{ -public: - enum - { - DEFAULT_SIZE = 100 - }; - - ACE_Thread_Manager (int = 0) {} - ~ACE_Thread_Manager (void) {} - - int open (size_t = DEFAULT_SIZE) { return -1; } - int close (void) { return -1; } - int spawn (ACE_THR_FUNC, - void * = 0, - long = 0, - ACE_thread_t * = 0, - ACE_hthread_t * = 0, - u_int = 0, - int = -1, - void * = 0, - size_t = 0) { return -1;} - int spawn_n (int, - ACE_THR_FUNC, - void * = 0, - long = 0, - u_int = 0, - int = -1 - ACE_Task_Base * = 0) { return -1;} - void *exit (void *) { return 0; } - void wait (const ACE_Time_Value * = 0) {} - int thread_descriptor (ACE_thread_t, ACE_Thread_Descriptor &) { return -1;} - int hthread_descriptor (ACE_hthread_t, ACE_Thread_Descriptor &) { return -1;} - int suspend_all (void) { return -1; } - int suspend (ACE_thread_t) { return -1; } - int suspend_grp (ACE_thread_t) { return -1; } - int resume_all (void) { return -1; } - int resume (ACE_thread_t) { return -1; } - int resume_grp (ACE_thread_t) { return -1; } - int kill_all (int) { return -1; } - int kill (ACE_thread_t) { return -1; } - int kill_grp (ACE_thread_t) { return -1; } - int cancel_all (void) { return -1; } - int cancel (int) { return -1; } - int cancel_grp (int) { return -1; } - void dump (void) const { } -}; - -class ACE_Export ACE_Thread_Control -{ -public: - ACE_Thread_Control (ACE_Thread_Manager * = 0, int = 0) {} - ~ACE_Thread_Control (void) {} - ACE_Thread_Manager *thr_mgr (void) { return 0; } - ACE_Thread_Manager *thr_mgr (ACE_Thread_Manager *) { return 0; } - void *exit (void *) { return 0; } - int insert (ACE_Thread_Manager *) { return 0; } - void *status (void *) { return 0; } - void *status (void) { return 0; } - void dump (void) const { } -}; -#else - // Forward declaration. class ACE_Thread_Control; @@ -400,8 +335,10 @@ private: // Keeps track of the next group id to assign. // = ACE_Thread_Mutex and condition variable for synchronizing termination. +#if defined (ACE_HAS_THREADS) ACE_Thread_Mutex lock_; ACE_Condition_Thread_Mutex zero_cond_; +#endif /* ACE_HAS_THREADS */ }; @@ -459,6 +396,5 @@ private: #include "ace/Thread_Manager.i" #endif /* __ACE_INLINE__ */ -#endif /* !defined (ACE_HAS_THREADS) */ #endif /* ACE_THREAD_MANAGER_H */ diff --git a/ace/Thread_Manager.i b/ace/Thread_Manager.i index 041b74cea66..97a8653e21b 100644 --- a/ace/Thread_Manager.i +++ b/ace/Thread_Manager.i @@ -39,8 +39,6 @@ ACE_Thread_Descriptor::state (void) return thr_state_; } -#if defined (ACE_HAS_THREADS) - // Set the exit status. ACE_INLINE void * @@ -79,5 +77,3 @@ ACE_Thread_Control::thr_mgr (ACE_Thread_Manager *tm) return this->tm_ = tm; return o_tm; } - -#endif /* !defined (ACE_HAS_THREADS) */ diff --git a/ace/Token_Invariants.h b/ace/Token_Invariants.h index eb40c9524a0..67507ee7764 100644 --- a/ace/Token_Invariants.h +++ b/ace/Token_Invariants.h @@ -97,11 +97,11 @@ public: // Dump the state of the class. private: - int readers_; - // Number of owning readers. - int writers_; // Number of owning writers. + + int readers_; + // Number of owning readers. }; class ACE_Export ACE_Token_Invariant_Manager diff --git a/ace/config-win32-msvc4.0.h b/ace/config-win32-msvc4.0.h index af03633ea15..fb529512dc5 100644 --- a/ace/config-win32-msvc4.0.h +++ b/ace/config-win32-msvc4.0.h @@ -7,9 +7,6 @@ #if !defined (ACE_CONFIG_H) #define ACE_CONFIG_H -// Needed for timeval. -#include <winsock.h> - #if defined (_MSC_VER) // "C4355: 'this' : used in base member initializer list" #pragma warning(disable:4355) // disable C4514 warning |