diff options
author | jcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-01-31 16:57:11 +0000 |
---|---|---|
committer | jcej <jcej@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1999-01-31 16:57:11 +0000 |
commit | ea604c0714a46eef1f159c31f17c3367147bcf22 (patch) | |
tree | 88c57b0e9ef579128c4e88b5bd7550a6f303bc98 /docs/tutorials/013 | |
parent | 67f212c9a6ca8293fd03ba5f208c52679b7dc542 (diff) | |
download | ATCD-ea604c0714a46eef1f159c31f17c3367147bcf22.tar.gz |
*** empty log message ***
Diffstat (limited to 'docs/tutorials/013')
-rw-r--r-- | docs/tutorials/013/combine.shar | 47 | ||||
-rw-r--r-- | docs/tutorials/013/message_queue.cpp | 4 | ||||
-rw-r--r-- | docs/tutorials/013/page01.html | 31 | ||||
-rw-r--r-- | docs/tutorials/013/page02.html | 6 | ||||
-rw-r--r-- | docs/tutorials/013/page03.html | 4 | ||||
-rw-r--r-- | docs/tutorials/013/page06.html | 16 | ||||
-rw-r--r-- | docs/tutorials/013/page07.html | 4 | ||||
-rw-r--r-- | docs/tutorials/013/task.cpp | 4 | ||||
-rw-r--r-- | docs/tutorials/013/task.h | 8 |
9 files changed, 93 insertions, 31 deletions
diff --git a/docs/tutorials/013/combine.shar b/docs/tutorials/013/combine.shar index e67be9253c5..feedd51e0a8 100644 --- a/docs/tutorials/013/combine.shar +++ b/docs/tutorials/013/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 1998-11-15 12:09 EST by <jcej@chiroptera.tragus.org>. +# Made on 1999-01-31 11:54 EST by <jcej@chiroptera.tragus.org>. # Source directory was `/var/home/jcej/projects/ACE_wrappers/docs/tutorials/013'. # # Existing files will *not* be overwritten unless `-c' is specified. @@ -13,7 +13,7 @@ # ------ ---------- ------------------------------------------ # 386 -rw-rw-r-- hdr # 89 -rw-rw-r-- bodies -# 976 -rw-rw-r-- page01.pre +# 2415 -rw-rw-r-- page01.pre # 432 -rw-rw-r-- page02.pre # 1426 -rw-rw-r-- page03.pre # 1049 -rw-rw-r-- page04.pre @@ -71,7 +71,7 @@ else fi rm -f 1231235999 $$.touch # -if mkdir _sh10945; then +if mkdir _sh30349; then $echo 'x -' 'creating lock directory' else $echo 'failed to create lock directory' @@ -145,8 +145,6 @@ if test -f 'page01.pre' && test "$first_param" != -c; then else $echo 'x -' extracting 'page01.pre' '(text)' sed 's/^X//' << 'SHAR_EOF' > 'page01.pre' && -X -X <P> <HR WIDTH="100%"> <P> @@ -168,20 +166,49 @@ method is called for finishing up any outstanding work. The chain of thread pools is uni-directional using a singly-linked list of Task derivatives. Each pool has the same number of tasks in order to keep things simple. +<P> +Kirthika's abstract: +<UL> +In this tutorial, a singly linked list of thread-pools, each of which is +a subtask and which acts as the finite state machine node, is used to +simulate a finite state machine. +<P> +A task is created with a number of subtasks. Once the message block is +obtained from the queue, it is verified to see whether a task has a +subtask. If so, it is forwarded to the subtask. Thus the mesage +traverses over the whole list. As a safety measure for destroying the +block after it goes through the whole list, an effective and simple +Memory Leak Detector has been implemented. It is a counter which +increments when the object where it resides is created and decrements on +its deletion. +<P> +Another optimisation from the previous tutorials on Message Queues, is +the bundling of the Data block within the Message Block. The Data block +provides reference counting, so duplication of data is avoided. It is +deleted only when its reference count drops to zero. Now updating +this count between threads call for synchronisation and in comes the +ACE_Mutex, a lock which takes care that the counting is thread-safe. +<P> +Although the example isn't a full-fledged Finite State Machine, +i.e. it has to be tweaked to be able to jump states on different inputs, +it definitely proves to be a great lesson and introduces us to quite a +few new ACE classes and the ways they can be mixed and matched to +produce the end-system desired. +</ul> SHAR_EOF - $shar_touch -am 1114225598 'page01.pre' && + $shar_touch -am 0131114799 'page01.pre' && chmod 0664 'page01.pre' || $echo 'restore of' 'page01.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 'page01.pre:' 'MD5 check failed' -391c8a4163bf85a87526b476ac9f0f99 page01.pre +52884c61973afc64e96c907493ebc216 page01.pre SHAR_EOF else shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`" - test 976 -eq "$shar_count" || - $echo 'page01.pre:' 'original size' '976,' 'current size' "$shar_count!" + test 2415 -eq "$shar_count" || + $echo 'page01.pre:' 'original size' '2415,' 'current size' "$shar_count!" fi fi # ============= page02.pre ============== @@ -630,5 +657,5 @@ SHAR_EOF $echo 'page07.pst:' 'original size' '371,' 'current size' "$shar_count!" fi fi -rm -fr _sh10945 +rm -fr _sh30349 exit 0 diff --git a/docs/tutorials/013/message_queue.cpp b/docs/tutorials/013/message_queue.cpp index 5238bd00ccb..4635304a460 100644 --- a/docs/tutorials/013/message_queue.cpp +++ b/docs/tutorials/013/message_queue.cpp @@ -14,9 +14,9 @@ int run_test (int iterations, int threads, int subtasks) // task.{h|cpp} for more details. Task *task = new Task (subtasks); - if (task->open (threads) == -1) + if (task->start (threads) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "open"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "start"), -1); } // Give the threads a chance to get ready. diff --git a/docs/tutorials/013/page01.html b/docs/tutorials/013/page01.html index 251a053aadc..f222eb01202 100644 --- a/docs/tutorials/013/page01.html +++ b/docs/tutorials/013/page01.html @@ -9,8 +9,6 @@ <CENTER><B><FONT SIZE=+2>ACE Tutorial 013</FONT></B></CENTER> <CENTER><B><FONT SIZE=+2>Multiple thread pools</FONT></B></CENTER> - - <P> <HR WIDTH="100%"> <P> @@ -32,5 +30,34 @@ method is called for finishing up any outstanding work. The chain of thread pools is uni-directional using a singly-linked list of Task derivatives. Each pool has the same number of tasks in order to keep things simple. +<P> +Kirthika's abstract: +<UL> +In this tutorial, a singly linked list of thread-pools, each of which is +a subtask and which acts as the finite state machine node, is used to +simulate a finite state machine. +<P> +A task is created with a number of subtasks. Once the message block is +obtained from the queue, it is verified to see whether a task has a +subtask. If so, it is forwarded to the subtask. Thus the mesage +traverses over the whole list. As a safety measure for destroying the +block after it goes through the whole list, an effective and simple +Memory Leak Detector has been implemented. It is a counter which +increments when the object where it resides is created and decrements on +its deletion. +<P> +Another optimisation from the previous tutorials on Message Queues, is +the bundling of the Data block within the Message Block. The Data block +provides reference counting, so duplication of data is avoided. It is +deleted only when its reference count drops to zero. Now updating +this count between threads call for synchronisation and in comes the +ACE_Mutex, a lock which takes care that the counting is thread-safe. +<P> +Although the example isn't a full-fledged Finite State Machine, +i.e. it has to be tweaked to be able to jump states on different inputs, +it definitely proves to be a great lesson and introduces us to quite a +few new ACE classes and the ways they can be mixed and matched to +produce the end-system desired. +</ul> <P><HR WIDTH="100%"> <CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page02.html">Continue This Tutorial</A>]</CENTER> diff --git a/docs/tutorials/013/page02.html b/docs/tutorials/013/page02.html index 7fca9f39265..85475ae7709 100644 --- a/docs/tutorials/013/page02.html +++ b/docs/tutorials/013/page02.html @@ -39,9 +39,9 @@ int run_test (int iterations, int threads, int subtasks) <font color=red>// task.{h|cpp} for more details.</font> Task *task = new Task (subtasks); - if (task->open (threads) == -1) + if (task->start (threads) == -1) { - ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>open</font>"), -1); + ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>start</font>"), -1); } <font color=red>// Give the threads a chance to get ready.</font> @@ -98,7 +98,7 @@ int main (int argc, char *argv[]) ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) Application exiting\n</font>")); - exit (0); + return (0); } <font color=blue>#if defined</font> (<font color=purple>ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION</font>) template class ACE_Guard < ACE_Mutex >; diff --git a/docs/tutorials/013/page03.html b/docs/tutorials/013/page03.html index 43a2d0832ca..3bb955c2b29 100644 --- a/docs/tutorials/013/page03.html +++ b/docs/tutorials/013/page03.html @@ -42,8 +42,8 @@ or I deleted too many times. Simple, cheap, effective. <P> <HR WIDTH="100%"> -<PRE> <HR width=50%><P><center>mld.h</center><HR width=50%> +<PRE> <font color=red>// $Id$</font> @@ -94,8 +94,8 @@ protected: <font color=blue>#endif</font> </PRE> -<PRE> <HR width=50%><P><center>mld.cpp</center><HR width=50%> +<PRE> <font color=red>// $Id$</font> diff --git a/docs/tutorials/013/page06.html b/docs/tutorials/013/page06.html index 66a71581c70..14d1cbb8402 100644 --- a/docs/tutorials/013/page06.html +++ b/docs/tutorials/013/page06.html @@ -33,8 +33,8 @@ There's not much to the header, so I've included it and the cpp file on this one page. <P> <HR WIDTH="100%"> -<PRE> <HR width=50%><P><center>task.h</center><HR width=50%> +<PRE> <font color=red>// $Id$</font> @@ -68,8 +68,12 @@ public: Task (int sub_tasks = 0); ~Task (void); - <font color=red>// Open the Task with the proper thread-pool size</font> - int open (int threads = 1); + <font color=red>/* + I really wanted this to be called open() but that was already + claimed by the Task framework. start() will kick off our thread + pool for us. + */</font> + int start (int threads = 1); <font color=red>// Take Unit_Of_Work objects from the thread pool and invoke</font> <font color=red>// their process() and/or fini() as appropriate.</font> @@ -89,8 +93,8 @@ protected: <font color=blue>#endif</font> </PRE> -<PRE> <HR width=50%><P><center>task.cpp</center><HR width=50%> +<PRE> <font color=red>// $Id$</font> @@ -130,11 +134,11 @@ protected: enabled, they inherit the thread-pool size. Make sure that the subtasks can be opened before we open our own threadpool. */</font> -int <font color=#008888>Task::open</font> (int threads) +int <font color=#008888>Task::start</font> (int threads) { if (next_) { - if (next_->open (threads) == -1) + if (next_->start (threads) == -1) { return -1; } diff --git a/docs/tutorials/013/page07.html b/docs/tutorials/013/page07.html index 415521d09e3..983878e676a 100644 --- a/docs/tutorials/013/page07.html +++ b/docs/tutorials/013/page07.html @@ -40,8 +40,8 @@ There's not much to this header either so I've combined it with the cpp file as with task. <P> <HR WIDTH="100%"> -<PRE> <HR width=50%><P><center>work.h</center><HR width=50%> +<PRE> <font color=red>// $Id$</font> @@ -115,8 +115,8 @@ protected: <font color=blue>#endif</font> </PRE> -<PRE> <HR width=50%><P><center>work.cpp</center><HR width=50%> +<PRE> <font color=red>// $Id$</font> diff --git a/docs/tutorials/013/task.cpp b/docs/tutorials/013/task.cpp index 6d6bf88b8cc..75c0a0d3341 100644 --- a/docs/tutorials/013/task.cpp +++ b/docs/tutorials/013/task.cpp @@ -37,11 +37,11 @@ Task::~Task (void) enabled, they inherit the thread-pool size. Make sure that the subtasks can be opened before we open our own threadpool. */ -int Task::open (int threads) +int Task::start (int threads) { if (next_) { - if (next_->open (threads) == -1) + if (next_->start (threads) == -1) { return -1; } diff --git a/docs/tutorials/013/task.h b/docs/tutorials/013/task.h index ced1ad15cf9..64f4064dfa0 100644 --- a/docs/tutorials/013/task.h +++ b/docs/tutorials/013/task.h @@ -31,8 +31,12 @@ public: Task (int sub_tasks = 0); ~Task (void); - // Open the Task with the proper thread-pool size - int open (int threads = 1); + /* + I really wanted this to be called open() but that was already + claimed by the Task framework. start() will kick off our thread + pool for us. + */ + int start (int threads = 1); // Take Unit_Of_Work objects from the thread pool and invoke // their process() and/or fini() as appropriate. |