summaryrefslogtreecommitdiff
path: root/docs
diff options
context:
space:
mode:
authorjcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-02-09 21:27:28 +0000
committerjcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795>1999-02-09 21:27:28 +0000
commit551a1571610acfcc26a49d191801fa60c61b8e44 (patch)
tree3433f9865b7372ced804ac0d242dfc1fe51c188d /docs
parent55ed125c54c77746536f982dfd93fd8ce929e39c (diff)
downloadATCD-551a1571610acfcc26a49d191801fa60c61b8e44.tar.gz
*** empty log message ***
Diffstat (limited to 'docs')
-rw-r--r--docs/tutorials/002/server.cpp6
-rw-r--r--docs/tutorials/010/combine.shar45
-rw-r--r--docs/tutorials/010/message_queue.cpp5
-rw-r--r--docs/tutorials/010/page02.html5
-rw-r--r--docs/tutorials/010/page04.html4
-rw-r--r--docs/tutorials/010/page05.html31
-rw-r--r--docs/tutorials/010/task.cpp18
-rw-r--r--docs/tutorials/010/task.h4
-rw-r--r--docs/tutorials/011/page02.html4
-rw-r--r--docs/tutorials/011/page03.html17
-rw-r--r--docs/tutorials/011/task.cpp13
-rw-r--r--docs/tutorials/011/task.h2
12 files changed, 74 insertions, 80 deletions
diff --git a/docs/tutorials/002/server.cpp b/docs/tutorials/002/server.cpp
index 7e46b080066..3066427c9cd 100644
--- a/docs/tutorials/002/server.cpp
+++ b/docs/tutorials/002/server.cpp
@@ -21,11 +21,15 @@ typedef ACE_Acceptor <Logging_Handler, ACE_SOCK_ACCEPTOR> Logging_Acceptor;
/* One of the new things will be a signal handler so that we can exit
the application somewhat cleanly. The 'finished' flag is used
instead of the previous infninite loop and the 'handler' will set
- that flag in respose to SIGINT (CTRL-C). */
+ that flag in respose to SIGINT (CTRL-C).
+ The invocation of ACE_Reactor::notify() will cause the
+ handle_events() to return so that we can see the new value of 'finished'.
+*/
static sig_atomic_t finished = 0;
extern "C" void handler (int)
{
finished = 1;
+ g_reactor->notify();
}
static const u_short PORT = ACE_DEFAULT_SERVER_PORT;
diff --git a/docs/tutorials/010/combine.shar b/docs/tutorials/010/combine.shar
index 543b0883550..ce6e2a2ef31 100644
--- a/docs/tutorials/010/combine.shar
+++ b/docs/tutorials/010/combine.shar
@@ -3,7 +3,7 @@
# To extract the files from this archive, save it to some FILE, remove
# everything before the `!/bin/sh' line above, then type `sh FILE'.
#
-# Made on 1999-01-24 15:41 EST by <jcej@chiroptera.tragus.org>.
+# Made on 1999-02-09 16:27 EST by <jcej@chiroptera.tragus.org>.
# Source directory was `/var/home/jcej/projects/ACE_wrappers/docs/tutorials/010'.
#
# Existing files will *not* be overwritten unless `-c' is specified.
@@ -13,15 +13,15 @@
# ------ ---------- ------------------------------------------
# 440 -rw-rw-r-- hdr
# 49 -rw-rw-r-- bodies
-# 2245 -rw-rw-r-- page01.pre
+# 2246 -rw-rw-r-- page01.pre
# 84 -rw-rw-r-- page02.pre
# 231 -rw-rw-r-- page03.pre
# 138 -rw-rw-r-- page04.pre
-# 75 -rw-rw-r-- page05.pre
+# 607 -rw-rw-r-- page05.pre
# 1493 -rw-rw-r-- page06.pre
# 444 -rw-rw-r-- page07.pre
# 689 -rw-rw-r-- page02.pst
-# 236 -rw-rw-r-- page03.pst
+# 237 -rw-rw-r-- page03.pst
# 387 -rw-rw-r-- page04.pst
# 366 -rw-rw-r-- page05.pst
#
@@ -70,7 +70,7 @@ else
fi
rm -f 1231235999 $$.touch
#
-if mkdir _sh24521; then
+if mkdir _sh15890; then
$echo 'x -' 'creating lock directory'
else
$echo 'failed to create lock directory'
@@ -197,12 +197,12 @@ SHAR_EOF
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'page01.pre:' 'MD5 check failed'
-976beee5fb40e6328b6e85ea66ad24c7 page01.pre
+84d1b63ff2eb7eecec515b248f73d791 page01.pre
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`"
- test 2245 -eq "$shar_count" ||
- $echo 'page01.pre:' 'original size' '2245,' 'current size' "$shar_count!"
+ test 2246 -eq "$shar_count" ||
+ $echo 'page01.pre:' 'original size' '2246,' 'current size' "$shar_count!"
fi
fi
# ============= page02.pre ==============
@@ -294,24 +294,35 @@ else
$echo 'x -' extracting 'page05.pre' '(text)'
sed 's/^X//' << 'SHAR_EOF' > 'page05.pre' &&
X
-Our <A HREF="task.cpp">Task</A> object definition:
+Our <A HREF="task.cpp">Task</A> object definition.
<P>
+Something to look at here is the ACE_Barrier usage. In the
+constructor, we tell the barrier how many threads we're using. Then,
+in the svc() method, we use the barrier's wait() method. You can
+think of the barrier as a semaphore initialized to the thread count.
+X Each time wait()
+is invoked, the semaphore is decremented and the thread is blocked.
+X When the count equals zero, all threads are unblocked and allowed to
+continue.
+<P>
+<font size=-1>Note: This isn't the way ACE_Barrier really works, it's
+just an analogy</font>
X
<HR WIDTH="100%">
SHAR_EOF
- $shar_touch -am 0124153399 'page05.pre' &&
+ $shar_touch -am 0209155699 'page05.pre' &&
chmod 0664 'page05.pre' ||
$echo 'restore of' 'page05.pre' 'failed'
if ( md5sum --help 2>&1 | grep 'sage: md5sum \[' ) >/dev/null 2>&1 \
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'page05.pre:' 'MD5 check failed'
-4d210e58ac8c908096af0bf9bf118847 page05.pre
+ff8f02648de795cd92f08141962d746d page05.pre
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page05.pre'`"
- test 75 -eq "$shar_count" ||
- $echo 'page05.pre:' 'original size' '75,' 'current size' "$shar_count!"
+ test 607 -eq "$shar_count" ||
+ $echo 'page05.pre:' 'original size' '607,' 'current size' "$shar_count!"
fi
fi
# ============= page06.pre ==============
@@ -465,12 +476,12 @@ SHAR_EOF
&& ( md5sum --version 2>&1 | grep -v 'textutils 1.12' ) >/dev/null; then
md5sum -c << SHAR_EOF >/dev/null 2>&1 \
|| $echo 'page03.pst:' 'MD5 check failed'
-c822867adfcc3d40e4997e7bd68d6404 page03.pst
+f0ce99c3625ad734730e7ac93efd2c8d page03.pst
SHAR_EOF
else
shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page03.pst'`"
- test 236 -eq "$shar_count" ||
- $echo 'page03.pst:' 'original size' '236,' 'current size' "$shar_count!"
+ test 237 -eq "$shar_count" ||
+ $echo 'page03.pst:' 'original size' '237,' 'current size' "$shar_count!"
fi
fi
# ============= page04.pst ==============
@@ -530,5 +541,5 @@ SHAR_EOF
$echo 'page05.pst:' 'original size' '366,' 'current size' "$shar_count!"
fi
fi
-rm -fr _sh24521
+rm -fr _sh15890
exit 0
diff --git a/docs/tutorials/010/message_queue.cpp b/docs/tutorials/010/message_queue.cpp
index 1cf1b0814b7..a0be6d5afa9 100644
--- a/docs/tutorials/010/message_queue.cpp
+++ b/docs/tutorials/010/message_queue.cpp
@@ -10,7 +10,7 @@ int
run_test (int iterations,
int threads)
{
- /* Create and star an instance of our Task object. */
+ /* Create and start an instance of our Task object. */
Task task (threads);
if (task.open () == -1)
@@ -79,8 +79,7 @@ main (int argc, char *argv[])
int iterations = argc > 1 ? atoi (argv[1]) : 9;
int threads = argc > 2 ? atoi (argv[2]) : 2;
- un_test (iterations,
- threads);
+ run_test (iterations, threads);
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Application exiting\n"));
diff --git a/docs/tutorials/010/page02.html b/docs/tutorials/010/page02.html
index 1ce9bc64e46..49beffefbd9 100644
--- a/docs/tutorials/010/page02.html
+++ b/docs/tutorials/010/page02.html
@@ -31,7 +31,7 @@ int
run_test (int iterations,
int threads)
{
- <font color=red>/* Create and star an instance of our Task object. */</font>
+ <font color=red>/* Create and start an instance of our Task object. */</font>
Task task (threads);
if (task.open () == -1)
@@ -100,8 +100,7 @@ main (int argc, char *argv[])
int iterations = argc > 1 ? atoi (argv[1]) : 9;
int threads = argc > 2 ? atoi (argv[2]) : 2;
- un_test (iterations,
- threads);
+ run_test (iterations, threads);
ACE_DEBUG ((LM_DEBUG,
"<font color=green>(%P|%t) Application exiting\n</font>"));
diff --git a/docs/tutorials/010/page04.html b/docs/tutorials/010/page04.html
index fb3cee4e3cb..03c1951ed42 100644
--- a/docs/tutorials/010/page04.html
+++ b/docs/tutorials/010/page04.html
@@ -55,9 +55,9 @@ public:
int close (u_long flags = 0);
protected:
- <font color=red>/* Just to be clever, jI'll use an ACE_Barrier to cause the threads
+ <font color=red>/* Just to be clever, I'll use an ACE_Barrier to cause the threads
to sync in svc() before doing any real work. */</font>
- ACE_Barrier *barrier_;
+ ACE_Barrier barrier_;
size_t n_threads_;
<font color=red>// Number of threads in the pool.</font>
diff --git a/docs/tutorials/010/page05.html b/docs/tutorials/010/page05.html
index d0ccb910270..dca2a02b74e 100644
--- a/docs/tutorials/010/page05.html
+++ b/docs/tutorials/010/page05.html
@@ -14,8 +14,19 @@
<P>
<HR WIDTH="100%">
-Our <A HREF="task.cpp">Task</A> object definition:
+Our <A HREF="task.cpp">Task</A> object definition.
<P>
+Something to look at here is the ACE_Barrier usage. In the
+constructor, we tell the barrier how many threads we're using. Then,
+in the svc() method, we use the barrier's wait() method. You can
+think of the barrier as a semaphore initialized to the thread count.
+ Each time wait()
+is invoked, the semaphore is decremented and the thread is blocked.
+ When the count equals zero, all threads are unblocked and allowed to
+continue.
+<P>
+<font size=-1>Note: This isn't the way ACE_Barrier really works, it's
+just an analogy</font>
<HR WIDTH="100%">
<PRE>
@@ -26,7 +37,7 @@ Our <A HREF="task.cpp">Task</A> object definition:
<font color=red>/* Set our housekeeping pointer to NULL and tell the user we exist. */</font>
<font color=#008888>Task::Task</font> (size_t n_threads)
- : barrier_ (0),
+ : barrier_ (n_threads),
n_threads_ (n_threads)
{
ACE_DEBUG ((LM_DEBUG,
@@ -49,25 +60,17 @@ Our <A HREF="task.cpp">Task</A> object definition:
until the last thread is done with the message block. */</font>
this->getq (message);
message->release ();
-
- delete barrier_;
}
-<font color=red>/* Open the object to do work. We create the Barrier object and tell
- it how many threads we'll be using. Next, we activate the Task into
- the number of requested threads. */</font>
+<font color=red>/* Open the object to do work. Next, we activate the Task into the
+ number of requested threads. */</font>
int
<font color=#008888>Task::open</font> (void *unused)
{
ACE_UNUSED_ARG (unused);
- barrier_;
-
- ACE_NEW_RETURN (barrier_,
- ACE_Barrier (this->n_threads_),
- -1);
return this->activate (THR_NEW_LWP,
- threads);
+ n_threads_);
}
<font color=red>/* Tell the user we're closing and invoke the baseclass' close() to
@@ -91,7 +94,7 @@ int
Task will get a shot at the queue until all of the threads are
active. There's no real need to do this but it's an easy intro
into the use of ACE_Barrier. */</font>
- this->barrier_->wait ();
+ this->barrier_.wait ();
ACE_DEBUG ((LM_DEBUG,
"<font color=green>(%P|%t) Task 0x%x starts in thread %d\n</font>",
diff --git a/docs/tutorials/010/task.cpp b/docs/tutorials/010/task.cpp
index 3b1a608daf2..8fa62ee0e7c 100644
--- a/docs/tutorials/010/task.cpp
+++ b/docs/tutorials/010/task.cpp
@@ -5,7 +5,7 @@
/* Set our housekeeping pointer to NULL and tell the user we exist. */
Task::Task (size_t n_threads)
- : barrier_ (0),
+ : barrier_ (n_threads),
n_threads_ (n_threads)
{
ACE_DEBUG ((LM_DEBUG,
@@ -28,25 +28,17 @@ Task::~Task (void)
until the last thread is done with the message block. */
this->getq (message);
message->release ();
-
- delete barrier_;
}
-/* Open the object to do work. We create the Barrier object and tell
- it how many threads we'll be using. Next, we activate the Task into
- the number of requested threads. */
+/* Open the object to do work. Next, we activate the Task into the
+ number of requested threads. */
int
Task::open (void *unused)
{
ACE_UNUSED_ARG (unused);
- barrier_;
-
- ACE_NEW_RETURN (barrier_,
- ACE_Barrier (this->n_threads_),
- -1);
return this->activate (THR_NEW_LWP,
- threads);
+ n_threads_);
}
/* Tell the user we're closing and invoke the baseclass' close() to
@@ -70,7 +62,7 @@ Task::svc (void)
Task will get a shot at the queue until all of the threads are
active. There's no real need to do this but it's an easy intro
into the use of ACE_Barrier. */
- this->barrier_->wait ();
+ this->barrier_.wait ();
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Task 0x%x starts in thread %d\n",
diff --git a/docs/tutorials/010/task.h b/docs/tutorials/010/task.h
index b0d4e56fe15..4e0b974a60d 100644
--- a/docs/tutorials/010/task.h
+++ b/docs/tutorials/010/task.h
@@ -34,9 +34,9 @@ public:
int close (u_long flags = 0);
protected:
- /* Just to be clever, jI'll use an ACE_Barrier to cause the threads
+ /* Just to be clever, I'll use an ACE_Barrier to cause the threads
to sync in svc() before doing any real work. */
- ACE_Barrier *barrier_;
+ ACE_Barrier barrier_;
size_t n_threads_;
// Number of threads in the pool.
diff --git a/docs/tutorials/011/page02.html b/docs/tutorials/011/page02.html
index 714b1927ca3..1e31b4a4694 100644
--- a/docs/tutorials/011/page02.html
+++ b/docs/tutorials/011/page02.html
@@ -27,9 +27,11 @@ the same as before, so I've only commented the changes.
<font color=blue>#include</font> "<font color=green>block.h</font>"
<font color=blue>#include</font> "<font color=green>data.h</font>"
-statuc int
+
+static int
run_test (int iterations,
int threads)
+
{
Task task (threads);
diff --git a/docs/tutorials/011/page03.html b/docs/tutorials/011/page03.html
index 4bbb5d3b62e..fcee526abbd 100644
--- a/docs/tutorials/011/page03.html
+++ b/docs/tutorials/011/page03.html
@@ -49,7 +49,7 @@ public:
int close (u_long flags = 0);
protected:
- ACE_Barrier *barrier_;
+ ACE_Barrier barrier_;
size_t n_threads_;
};
@@ -65,7 +65,7 @@ protected:
<font color=blue>#include</font> "<font color=green>data.h</font>"
<font color=#008888>Task::Task</font> (size_t n_threads)
- : barrier_ (0),
+ : barrier_ (n_threads),
n_threads_ (n_threads)
{
ACE_DEBUG ((LM_DEBUG,
@@ -82,21 +82,14 @@ protected:
ACE_Message_Block *message;
this->getq (message);
message->release ();
-
- delete barrier_;
}
int
<font color=#008888>Task::open</font> (void *)
{
- barrier_;
-
- ACE_NEW_RETURN (barrier_,
- ACE_Barrier (this->n_threads_),
- -1);
-
return this->activate (THR_NEW_LWP,
- threads);
+ this->n_threads_);
+
}
int
@@ -111,7 +104,7 @@ int
int
<font color=#008888>Task::svc</font> (void)
{
- this->barrier_->wait ();
+ this->barrier_.wait ();
ACE_DEBUG ((LM_DEBUG,
"<font color=green>(%P|%t) Task 0x%x starts in thread %d\n</font>",
diff --git a/docs/tutorials/011/task.cpp b/docs/tutorials/011/task.cpp
index 1451aaa0b9a..c0e95d21921 100644
--- a/docs/tutorials/011/task.cpp
+++ b/docs/tutorials/011/task.cpp
@@ -5,7 +5,7 @@
#include "data.h"
Task::Task (size_t n_threads)
- : barrier_ (0),
+ : barrier_ (n_threads),
n_threads_ (n_threads)
{
ACE_DEBUG ((LM_DEBUG,
@@ -22,20 +22,11 @@ Task::~Task (void)
ACE_Message_Block *message;
this->getq (message);
message->release ();
-
- delete barrier_;
}
int
Task::open (void *)
{
-
- barrier_;
-
- ACE_NEW_RETURN (barrier_,
- ACE_Barrier (this->n_threads_),
- -1);
-
return this->activate (THR_NEW_LWP,
this->n_threads_);
@@ -53,7 +44,7 @@ Task::close (u_long flags)
int
Task::svc (void)
{
- this->barrier_->wait ();
+ this->barrier_.wait ();
ACE_DEBUG ((LM_DEBUG,
"(%P|%t) Task 0x%x starts in thread %d\n",
diff --git a/docs/tutorials/011/task.h b/docs/tutorials/011/task.h
index a59f4fda029..c1883bb871a 100644
--- a/docs/tutorials/011/task.h
+++ b/docs/tutorials/011/task.h
@@ -25,7 +25,7 @@ public:
int close (u_long flags = 0);
protected:
- ACE_Barrier *barrier_;
+ ACE_Barrier barrier_;
size_t n_threads_;
};