summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorjcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-29 23:21:50 +0000
committerjcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1998-09-29 23:21:50 +0000
commitefd96764c5fadf966e3ae1366d3e865fc4ca00a7 (patch)
tree47c1207aee91c67f5204f3bf3d958582bbafa10a /docs
parentfd18e6f89ef2a1abc244c94505abc8c39e92ea64 (diff)
downloadATCD-efd96764c5fadf966e3ae1366d3e865fc4ca00a7.tar.gz
*** empty log message ***
Diffstat (limited to 'docs')
-rw-r--r--docs/tutorials/007/thread_pool.cpp2
-rw-r--r--docs/tutorials/007/thread_pool.h37
2 files changed, 29 insertions, 10 deletions
diff --git a/docs/tutorials/007/thread_pool.cpp b/docs/tutorials/007/thread_pool.cpp
index 49435a2a748..0719243df84 100644
--- a/docs/tutorials/007/thread_pool.cpp
+++ b/docs/tutorials/007/thread_pool.cpp
@@ -31,7 +31,7 @@ int Thread_Pool::open( int _pool_size )
Closing the thread pool can be a tricky exercise. I've decided to take an easy approach
and simply enqueue a secret message for each thread we have active.
*/
-int Thread_Pool::close(void)
+int Thread_Pool::close( void )
{
/*
Find out how many threads are currently active
diff --git a/docs/tutorials/007/thread_pool.h b/docs/tutorials/007/thread_pool.h
index 5fae81fae72..ebf2e162ce4 100644
--- a/docs/tutorials/007/thread_pool.h
+++ b/docs/tutorials/007/thread_pool.h
@@ -27,6 +27,8 @@ class Thread_Pool : public ACE_Task<ACE_MT_SYNCH>
{
public:
+ typedef ACE_Task<ACE_MT_SYNCH> inherited;
+
/*
Provide an enumeration for the default pool size. By doing this, other objects
can use the value when they want a default.
@@ -45,11 +47,28 @@ public:
*/
int open( int _pool_size = default_pool_size_ );
+ /*
+ Some compilers will complain that our open() above attempts to
+ override a virtual function in the baseclass. We have no
+ intention of overriding that method but in order to keep the
+ compiler quiet we have to add this method as a pass-thru to the
+ baseclass method.
+ */
+ virtual int open(void * _void_data)
+ { return inherited::open(_void_data); }
+
/*
When you're done wit the thread pool, you have to have some way to shut it down.
This is what close() is for.
*/
- int close(void);
+ int close( void );
+
+ /*
+ Just like open() we have to provide a bogus method that will
+ invoke the baseclass close() to keep some compilers quiet.
+ */
+ virtual int close( u_long flags )
+ { return inherited::close(flags); }
/*
To use the thread pool, you have to put some unit of work into it. Since we're
@@ -60,6 +79,14 @@ public:
*/
int enqueue( ACE_Event_Handler * _handler );
+ /*
+ Another handy ACE template is ACE_Atomic_Op<>. When parameterized, this allows
+ is to have a thread-safe counting object. The typical arithmetic operators are
+ all internally thread-safe so that you can share it across threads without worrying
+ about any contention issues.
+ */
+ typedef ACE_Atomic_Op<ACE_Mutex,int> counter_t;
+
protected:
/*
@@ -71,14 +98,6 @@ protected:
int svc(void);
/*
- Another handy ACE template is ACE_Atomic_Op<>. When parameterized, this allows
- is to have a thread-safe counting object. The typical arithmetic operators are
- all internally thread-safe so that you can share it across threads without worrying
- about any contention issues.
- */
- typedef ACE_Atomic_Op<ACE_Mutex,int> counter_t;
-
- /*
We use the atomic op to keep a count of the number of threads in which our svc()
method is running. This is particularly important when we want to close() it down!
*/