summaryrefslogtreecommitdiff
path: root/docs/tutorials/013
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/013')
-rw-r--r--docs/tutorials/013/013.dsp132
-rw-r--r--docs/tutorials/013/Makefile74
-rw-r--r--docs/tutorials/013/block.cpp81
-rw-r--r--docs/tutorials/013/block.h84
-rw-r--r--docs/tutorials/013/combine.shar661
-rw-r--r--docs/tutorials/013/message_queue.cpp88
-rw-r--r--docs/tutorials/013/mld.cpp23
-rw-r--r--docs/tutorials/013/mld.h49
-rw-r--r--docs/tutorials/013/page01.html64
-rw-r--r--docs/tutorials/013/page02.html123
-rw-r--r--docs/tutorials/013/page03.html125
-rw-r--r--docs/tutorials/013/page04.html140
-rw-r--r--docs/tutorials/013/page05.html108
-rw-r--r--docs/tutorials/013/page06.html303
-rw-r--r--docs/tutorials/013/page07.html257
-rw-r--r--docs/tutorials/013/page08.html42
-rw-r--r--docs/tutorials/013/task.cpp193
-rw-r--r--docs/tutorials/013/task.h57
-rw-r--r--docs/tutorials/013/work.cpp125
-rw-r--r--docs/tutorials/013/work.h72
20 files changed, 0 insertions, 2801 deletions
diff --git a/docs/tutorials/013/013.dsp b/docs/tutorials/013/013.dsp
deleted file mode 100644
index 92f6469a27e..00000000000
--- a/docs/tutorials/013/013.dsp
+++ /dev/null
@@ -1,132 +0,0 @@
-# Microsoft Developer Studio Project File - Name="013" - Package Owner=<4>
-# Microsoft Developer Studio Generated Build File, Format Version 6.00
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-CFG=013 - Win32 Debug
-!MESSAGE This is not a valid makefile. To build this project using NMAKE,
-!MESSAGE use the Export Makefile command and run
-!MESSAGE
-!MESSAGE NMAKE /f "013.mak".
-!MESSAGE
-!MESSAGE You can specify a configuration when running NMAKE
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "013.mak" CFG="013 - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "013 - Win32 Release" (based on "Win32 (x86) Console Application")
-!MESSAGE "013 - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE
-
-# Begin Project
-# PROP Scc_ProjName ""
-# PROP Scc_LocalPath ""
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "013 - Win32 Release"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 0
-# PROP BASE Output_Dir "Release"
-# PROP BASE Intermediate_Dir "Release"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 0
-# PROP Output_Dir "Release"
-# PROP Intermediate_Dir "Release"
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MD /W3 /GX /O2 /I "..\..\.." /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "NDEBUG"
-# ADD RSC /l 0x409 /d "NDEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
-# ADD LINK32 ace.lib /nologo /subsystem:console /machine:I386 /libpath:"..\..\..\ace"
-
-!ELSEIF "$(CFG)" == "013 - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "Debug"
-# PROP BASE Intermediate_Dir "Debug"
-# PROP BASE Target_Dir ""
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir "Debug"
-# PROP Intermediate_Dir "Debug"
-# PROP Ignore_Export_Lib 0
-# PROP Target_Dir ""
-# ADD BASE CPP /nologo /W3 /GX /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
-# ADD CPP /nologo /MDd /W3 /GX /Od /I "..\..\.." /D "WIN32" /D "_DEBUG" /YX /FD /c
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
-# ADD LINK32 aced.lib /nologo /subsystem:console /debug /machine:I386 /out:"message_queue.exe" /pdbtype:sept /libpath:"..\..\..\ace"
-
-!ENDIF
-
-# Begin Target
-
-# Name "013 - Win32 Release"
-# Name "013 - Win32 Debug"
-# Begin Group "Source Files"
-
-# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
-# Begin Source File
-
-SOURCE=.\block.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\message_queue.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\mld.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\task.cpp
-# End Source File
-# Begin Source File
-
-SOURCE=.\work.cpp
-# End Source File
-# End Group
-# Begin Group "Header Files"
-
-# PROP Default_Filter "h;hpp;hxx;hm;inl"
-# Begin Source File
-
-SOURCE=.\block.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\mld.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\task.h
-# End Source File
-# Begin Source File
-
-SOURCE=.\work.h
-# End Source File
-# End Group
-# Begin Group "Resource Files"
-
-# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
-# End Group
-# End Target
-# End Project
diff --git a/docs/tutorials/013/Makefile b/docs/tutorials/013/Makefile
deleted file mode 100644
index c150df6639c..00000000000
--- a/docs/tutorials/013/Makefile
+++ /dev/null
@@ -1,74 +0,0 @@
-
-# $Id$
-
-#----------------------------------------------------------------------------
-# Local macros
-#----------------------------------------------------------------------------
-
-BIN = message_queue
-
-FILES = task block work mld
-
-BUILD = $(VBIN)
-
-SRC = $(addsuffix .cpp,$(BIN))
-SRC += $(addsuffix .cpp,$(FILES))
-
-HDR = *.h
-
-#----------------------------------------------------------------------------
-# Include macros and targets
-#----------------------------------------------------------------------------
-
-include $(ACE_ROOT)/include/makeinclude/wrapper_macros.GNU
-include $(ACE_ROOT)/include/makeinclude/macros.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.common.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.nonested.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.bin.GNU
-include $(ACE_ROOT)/include/makeinclude/rules.local.GNU
-
-#----------------------------------------------------------------------------
-# Local targets
-#----------------------------------------------------------------------------
-
-Indent : #
- for i in $(SRC) $(HDR) ; do \
- indent -npsl -l80 -fca -fc1 -cli0 -cdb -ts2 -bl -bli0 < $$i | \
- sed -e 's/: :/::/g' \
- -e 's/^.*\(public:\)/\1/' \
- -e 's/^.*\(protected:\)/\1/' \
- -e 's/^.*\(private:\)/\1/' \
- -e 's/:\(public\)/ : \1/' \
- -e 's/:\(protected\)/ : \1/' \
- -e 's/:\(private\)/ : \1/' \
- -e 's/ / /g' \
- > $$i~ ;\
- mv $$i~ $$i ;\
- done
-
-Depend : depend
- perl ../fix.Makefile
-
-HTML : #
- [ -f hdr ] || $(MAKE) UNSHAR
- perl ../combine *.pre
- chmod +r *.html
-
-SHAR : #
- [ ! -f combine.shar ] || exit 1
- shar -T hdr bodies *.pre *.pst > combine.shar && $(RM) hdr bodies *.pre *.pst
-
-UNSHAR : #
- sh combine.shar
-
-CLEAN : realclean
- $(RM) hdr bodies *.pre *.pst .depend
-
-.depend : #
- touch .depend
-
-#----------------------------------------------------------------------------
-# Dependencies
-#----------------------------------------------------------------------------
-
-include .depend
diff --git a/docs/tutorials/013/block.cpp b/docs/tutorials/013/block.cpp
deleted file mode 100644
index e652d33643a..00000000000
--- a/docs/tutorials/013/block.cpp
+++ /dev/null
@@ -1,81 +0,0 @@
-
-// $Id$
-
-#include "block.h"
-
-/*
- Construct a Dat_Block to contain a unit of work. Note the careful
- construction of the baseclass to set the block type and the locking
- strategy.
- */
-Data_Block::Data_Block (Unit_Of_Work * _data)
- : ACE_Data_Block (0, ACE_Message_Block::MB_DATA, 0, 0, new Lock (), 0, 0)
- ,data_ (_data)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Data_Block ctor for 0x%x\n", (void *) this, (void *) data_));
-}
-
-/*
- The Lock object created in the constructor is stored in the baseclass and
- available through the locking_strategy() method. We can cast it's value to
- our Lock object and invoke the destroy() to indicate that we want it to go
- away when the lock is released.
- */
-Data_Block::~Data_Block (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Data_Block dtor for 0x%x\n", (void *) this, (void *) data_));
- ((Lock *) locking_strategy ())->destroy ();
- delete data_;
-}
-
-/*
- Return the data
- */
-Unit_Of_Work *Data_Block::data (void)
-{
- return this->data_;
-}
-
-Data_Block:: Lock::Lock (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Lock ctor\n", (void *) this));
-}
-
-Data_Block:: Lock::~Lock (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Lock dtor\n", (void *) this));
-}
-
-/*
- Delete ourselves to prevent any memory leak
- */
-int Data_Block::Lock::destroy (void)
-{
- delete this;
- return (0);
-}
-
-/*
- Create an baseclass unit of work when we instantiate a hangup message.
- */
-Message_Block::Message_Block (void)
- :ACE_Message_Block (new Data_Block (new Unit_Of_Work ()))
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Message_Block ctor for shutdown\n", (void *) this));
- this->msg_type (MB_HANGUP);
-}
-
-/*
- Store the unit of work in a Data_Block and initialize the baseclass with
- that data.
- */
-Message_Block::Message_Block (Unit_Of_Work * _data)
- :ACE_Message_Block (new Data_Block (_data))
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Message_Block ctor for 0x%x\n", (void *) this, (void *) _data));
-}
-
-Message_Block::~Message_Block (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Message_Block dtor\n", (void *) this));
-}
diff --git a/docs/tutorials/013/block.h b/docs/tutorials/013/block.h
deleted file mode 100644
index 91261c3ecd0..00000000000
--- a/docs/tutorials/013/block.h
+++ /dev/null
@@ -1,84 +0,0 @@
-
-// $Id$
-
-#ifndef BLOCK_H
-#define BLOCK_H
-
-#include "ace/Message_Block.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/Synch.h"
-#include "mld.h"
-#include "work.h"
-
-/*
- In this Tutorial, we derive from ACE_Data_Block for our special data. With
- the possiblilty that our Task object may forward the unit of work on to
- another thread pool, we have to make sure that the data object doesn't go
- out of scope unexpectedly. An ACE_Message_Block will be deleted as soon as
- it's release() method is called but the ACE_Data_Blocks it uses are
- reference counted and only delete when the last reference release()es the
- block. We use that trait to simplify our object memory management.
- */
-class Data_Block : public ACE_Data_Block
-{
-public:
- typedef ACE_Data_Block inherited;
-
- // Create a data block with a unit of work to be done
- Data_Block (Unit_Of_Work * _data);
-
- ~Data_Block (void);
-
- // Returns the work pointer
- Unit_Of_Work *data (void);
-
-protected:
- Unit_Of_Work * data_;
- MLD; // Our memory leak detector
-
- // The ACE_Data_Block allows us to choose a locking strategy
- // for making the reference counting thread-safe. The
- // ACE_Lock_Adaptor<> template adapts the interface of a
- // number of lock objects so that the ACE_Message_Block will
- // have an interface it can use.
- class Lock : public ACE_Lock_Adapter < ACE_Mutex >
- {
- public:
- typedef ACE_Lock_Adapter < ACE_Mutex > inherited;
-
- Lock (void);
- ~Lock (void);
-
- // destroy() will be called to explicitly delete the
- // lock when we no longer need it. The method will then
- // cleanup to prevent any memory leaks.
- int destroy (void);
-
- protected:
- MLD;
- };
-};
-
-/*
- This simple derivative of ACE_Message_Block will construct our Data_Block
- object to contain a unit of work.
- */
-class Message_Block : public ACE_Message_Block
-{
-public:
- typedef ACE_Message_Block inherited;
-
- Message_Block (void);
- Message_Block (Unit_Of_Work * _data);
-
- ~Message_Block (void);
-
-protected:
- MLD;
-};
-
-#endif
diff --git a/docs/tutorials/013/combine.shar b/docs/tutorials/013/combine.shar
deleted file mode 100644
index b640ea8da26..00000000000
--- a/docs/tutorials/013/combine.shar
+++ /dev/null
@@ -1,661 +0,0 @@
-#!/bin/sh
-# This is a shell archive (produced by GNU sharutils 4.2).
-# 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-09-21 22:49 EDT by <jcej@chiroptera.tragus.org>.
-# Source directory was `/home/jcej/projects/ACE_wrappers/docs/tutorials/013'.
-#
-# Existing files will *not* be overwritten unless `-c' is specified.
-#
-# This shar contains:
-# length mode name
-# ------ ---------- ------------------------------------------
-# 386 -rw-rw-r-- hdr
-# 89 -rw-rw-r-- bodies
-# 2416 -rw-rw-r-- page01.pre
-# 432 -rw-rw-r-- page02.pre
-# 1426 -rw-rw-r-- page03.pre
-# 1049 -rw-rw-r-- page04.pre
-# 268 -rw-rw-r-- page05.pre
-# 914 -rw-rw-r-- page06.pre
-# 1368 -rw-rw-r-- page07.pre
-# 862 -rw-rw-r-- page08.pre
-# 204 -rw-rw-r-- page02.pst
-# 704 -rw-rw-r-- page04.pst
-# 386 -rw-rw-r-- page06.pst
-# 371 -rw-rw-r-- page07.pst
-#
-save_IFS="${IFS}"
-IFS="${IFS}:"
-gettext_dir=FAILED
-locale_dir=FAILED
-first_param="$1"
-for dir in $PATH
-do
- if test "$gettext_dir" = FAILED && test -f $dir/gettext \
- && ($dir/gettext --version >/dev/null 2>&1)
- then
- set `$dir/gettext --version 2>&1`
- if test "$3" = GNU
- then
- gettext_dir=$dir
- fi
- fi
- if test "$locale_dir" = FAILED && test -f $dir/shar \
- && ($dir/shar --print-text-domain-dir >/dev/null 2>&1)
- then
- locale_dir=`$dir/shar --print-text-domain-dir`
- fi
-done
-IFS="$save_IFS"
-if test "$locale_dir" = FAILED || test "$gettext_dir" = FAILED
-then
- echo=echo
-else
- TEXTDOMAINDIR=$locale_dir
- export TEXTDOMAINDIR
- TEXTDOMAIN=sharutils
- export TEXTDOMAIN
- echo="$gettext_dir/gettext -s"
-fi
-touch -am 1231235999 $$.touch >/dev/null 2>&1
-if test ! -f 1231235999 && test -f $$.touch; then
- shar_touch=touch
-else
- shar_touch=:
- echo
- $echo 'WARNING: not restoring timestamps. Consider getting and'
- $echo "installing GNU \`touch', distributed in GNU File Utilities..."
- echo
-fi
-rm -f 1231235999 $$.touch
-#
-if mkdir _sh05033; then
- $echo 'x -' 'creating lock directory'
-else
- $echo 'failed to create lock directory'
- exit 1
-fi
-# ============= hdr ==============
-if test -f 'hdr' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'hdr' '(file already exists)'
-else
- $echo 'x -' extracting 'hdr' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'hdr' &&
-<HTML>
-<HEAD>
-X <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
-X <META NAME="Author" CONTENT="James CE Johnson">
-X <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-X
-<CENTER><B><FONT SIZE=+2>ACE Tutorial 013</FONT></B></CENTER>
-X
-<CENTER><B><FONT SIZE=+2>Multiple thread pools</FONT></B></CENTER>
-SHAR_EOF
- $shar_touch -am 1114225598 'hdr' &&
- chmod 0664 'hdr' ||
- $echo 'restore of' 'hdr' '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 'hdr:' 'MD5 check failed'
-abef9831eba4051526151ff2343730d7 hdr
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'hdr'`"
- test 386 -eq "$shar_count" ||
- $echo 'hdr:' 'original size' '386,' 'current size' "$shar_count!"
- fi
-fi
-# ============= bodies ==============
-if test -f 'bodies' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'bodies' '(file already exists)'
-else
- $echo 'x -' extracting 'bodies' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'bodies' &&
-PAGE=2
-message_queue.cpp
-mld.h mld.cpp
-block.h
-block.cpp
-task.h task.cpp
-work.h work.cpp
-SHAR_EOF
- $shar_touch -am 1114230198 'bodies' &&
- chmod 0664 'bodies' ||
- $echo 'restore of' 'bodies' '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 'bodies:' 'MD5 check failed'
-826e1e15e593f64228b867cb6143f179 bodies
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'bodies'`"
- test 89 -eq "$shar_count" ||
- $echo 'bodies:' 'original size' '89,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page01.pre ==============
-if test -f 'page01.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page01.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page01.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page01.pre' &&
-<P>
-<HR WIDTH="100%">
-<P>
-My intent with this tutorial was to derive from ACE_Data_Block instead
-of ACE_Message_Block so that we could leverage the reference counting
-nature of that object.
-<P>
-Along the way, I sort of got distracted... What I ended up with is a
-poor excuse for ACE_Stream that implements a simple state machine.
-<P>
-The application is built around a thread pool where the pool's svc()
-method takes work units from the message queue for processing. As
-each unit is taken from the queue, the process() method is invoked to
-do some work. The twist is that after processing the message, we
-enqueue it into another thread pool to do more work. This continues
-through a chain of thread pools until the last where the unit's fini()
-method is called for finishing up any outstanding work.
-<P>
-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 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'
-2448d57199e11bc55ce9cb9cb3ada738 page01.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page01.pre'`"
- test 2416 -eq "$shar_count" ||
- $echo 'page01.pre:' 'original size' '2416,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page02.pre ==============
-if test -f 'page02.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page02.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page02.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page02.pre' &&
-X
-X
-<P>
-<HR WIDTH="100%">
-<P>
-We'll go back to our tradition of looking at main() first. The only
-change here from our "normal" thread pool is the ability to specify
-the number of subtasks for the pool. (Each subtask is another thread
-pool in the chain. I suppose I should have named that better...)
-I've still got the custom Message_Block so that, at this level, we
-don't even know about custom Data_Blocks.
-<P>
-<HR WIDTH="100%">
-SHAR_EOF
- $shar_touch -am 1114225598 'page02.pre' &&
- chmod 0664 'page02.pre' ||
- $echo 'restore of' 'page02.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 'page02.pre:' 'MD5 check failed'
-6f4a2e24d7d776b1ec17a07f00f409f8 page02.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page02.pre'`"
- test 432 -eq "$shar_count" ||
- $echo 'page02.pre:' 'original size' '432,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page03.pre ==============
-if test -f 'page03.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page03.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page03.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page03.pre' &&
-X
-X
-<P>
-<HR WIDTH="100%">
-<P>
-I did eventually create that ACE_Data_Block derivative that I wanted.
-My purpose in doing so was to use the reference-counting
-that is provided by ACE_Data_Block and ACE_Message_Block interactions.
-X When you're working with an object in a single
-thread, it's generally not so difficult to manage it's lifetime.
-That is, it doesn't tend to go out of scope or get destroyed unless
-you do it on purpose.
-<P>
-On the other hand, if you're passing data between several threads, it
-is easy to loose track of who "owns" the data at any one time. All
-too frequently, data will be deleted by one thread while another is
-still using it. Reference counting can prevent that. The rule of
-thumb is that you increment the reference count of the object when you
-hand it off to a new thread. You then decrement the count when you're
-done with the object and let the object delete itself when there are
-no more references.
-<P>
-To prove that all of that works correctly in the tutorial, I've
-created a cheap Memory Leak Detector object. All mld instances
-reference a thread-safe counter that is incremented when the mld is
-constructed and decremented when destructed. I then insert an mld
-into each of my dynamically created objects. If I get to the end of
-main() and the counter isn't zero then I either didn't delete enough
-or I deleted too many times.
-<P>
-Simple, cheap, effective.
-<P>
-<HR WIDTH="100%">
-SHAR_EOF
- $shar_touch -am 1114225598 'page03.pre' &&
- chmod 0664 'page03.pre' ||
- $echo 'restore of' 'page03.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 'page03.pre:' 'MD5 check failed'
-e4c0dfb0a761a258adeba509ac6c2062 page03.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page03.pre'`"
- test 1426 -eq "$shar_count" ||
- $echo 'page03.pre:' 'original size' '1426,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page04.pre ==============
-if test -f 'page04.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page04.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page04.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page04.pre' &&
-X
-X
-<P>
-<HR WIDTH="100%">
-<P>
-Let's look now at the changes to our ACE_Message_Block derivative and
-the new ACE_Data_Block derivative.
-<P>
-The important thing to remember is that the data block (not the
-message block) is reference counted. When you instantiate a new
-ACE_Message_Block, it will create one or more ACE_Data_Block objects
-to contain the data you need. Optionally, you can provide it with a
-pointer to a data block.
-<P>
-When you finish with a message block, you should use the release()
-method to make it go away. Do not ever <em>delete</em> an instance of
-a message block! When you invoke release(), the message block will
-invoke release() on the data block(s) it contains. If the block's
-reference count goes to zero as a result then the block will <em>delete</em>
-itself.
-<P>
-To increment the reference count of a data block, use the
-duplicate() method of the message block (or blocks) to get a new
-message block referencing the same data block. This is very efficient
-since the actual data is not copied.
-<P>
-<HR WIDTH="100%">
-SHAR_EOF
- $shar_touch -am 1114225598 'page04.pre' &&
- chmod 0664 'page04.pre' ||
- $echo 'restore of' 'page04.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 'page04.pre:' 'MD5 check failed'
-05d0560194222144a3a599b4d88990ff page04.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page04.pre'`"
- test 1049 -eq "$shar_count" ||
- $echo 'page04.pre:' 'original size' '1049,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page05.pre ==============
-if test -f 'page05.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page05.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page05.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page05.pre' &&
-X
-X
-<P>
-<HR WIDTH="100%">
-<P>
-On this page we have the code for the Data_Block and Message_Block
-objects. As you probably suspect from the header on the previous
-page, the complicated part is in the construction and destruction of
-the Data_Block.
-<P>
-<HR WIDTH="100%">
-SHAR_EOF
- $shar_touch -am 1114225598 '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'
-a95fdcd3db2356b091228728f4f3f130 page05.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page05.pre'`"
- test 268 -eq "$shar_count" ||
- $echo 'page05.pre:' 'original size' '268,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page06.pre ==============
-if test -f 'page06.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page06.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page06.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page06.pre' &&
-X
-X
-<P>
-<HR WIDTH="100%">
-<P>
-Let's take a look now at the new Task object. This will obviously be
-different from the Tasks we've created before but I think you'll be
-surprised at how relatively simple it actually is.
-<P>
-Remember that the goal of this tutorial was to use the reference
-counting abilities of the ACE_Data_Block. The only way to show that
-effectively is to have a data block passed between different threads.
-A thread pool isn't really going to do that so, instead, our new Task
-can be part of a chain of tasks. In that way, each Task can pass the
-data on to another and satisfy our need for moving the ACE_Data_Block
-around.
-If we've done the reference counting correctly then none of our tasks
-will be trying to work with deleted data and we won't have any memory
-leaks at the end.
-<P>
-There's not much to the header, so I've included it and the cpp file
-on this one page.
-<P>
-<HR WIDTH="100%">
-SHAR_EOF
- $shar_touch -am 1114225698 'page06.pre' &&
- chmod 0664 'page06.pre' ||
- $echo 'restore of' 'page06.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 'page06.pre:' 'MD5 check failed'
-a4c9b50df3240c5134733d2033fd5f03 page06.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page06.pre'`"
- test 914 -eq "$shar_count" ||
- $echo 'page06.pre:' 'original size' '914,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page07.pre ==============
-if test -f 'page07.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page07.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page07.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page07.pre' &&
-X
-X
-<P>
-<HR WIDTH="100%">
-<P>
-I've been trying to justify the chain of tasks by talking about a
-Work object that implements a state machine. The idea is that your
-Work object has to perform a series of discrete steps to complete it's
-function. Traditionally, all of those steps would take place in one
-thread of execution. That thread would probably be one from a Task
-thread pool.
-<P>
-Suppose, however, that some of those steps spend a lot of time waiting
-for disk IO. You could find that all of your thread-pool threads
-are just sitting there waiting for the disk. You might then be
-tempted to increase the thread pool size to get more work through.
-However, if some of the stages are memory intensive, you could run out
-of memory if all of the workers get to that state at the same time.
-<P>
-One solution might be to have different thread pools for each state.
-Each pool could have it's size tuned appropriately for the work that
-would be done there. That's where the chain of Tasks comes in.
-X In this tutorial's implementation I've taken the
-easy route and set all of the thread pools to the same size but a more
-realistic solution would be to set each thread pool in the chain to a
-specific size as needed by that state of operation.
-<P>
-There's not much to this header either so I've combined it with the
-cpp file as with task.
-<P>
-<HR WIDTH="100%">
-SHAR_EOF
- $shar_touch -am 1114225698 'page07.pre' &&
- chmod 0664 'page07.pre' ||
- $echo 'restore of' 'page07.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 'page07.pre:' 'MD5 check failed'
-9bd5ac0cf6ff9786f3f99602a282146d page07.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page07.pre'`"
- test 1368 -eq "$shar_count" ||
- $echo 'page07.pre:' 'original size' '1368,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page08.pre ==============
-if test -f 'page08.pre' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page08.pre' '(file already exists)'
-else
- $echo 'x -' extracting 'page08.pre' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page08.pre' &&
-X
-X
-<P>
-<HR WIDTH="100%">
-<P>
-And that's the end of another tutorial. This one is probably the most
-complicated so far because I've introduced or expanded upon
-a number of different
-concepts. Namely: state machines, reference counting and task
-chaining. I hope I didn't complicate things to the point where the
-lesson got lost in the noise. As always, feel free to drop a note to
-the ACE-Users mailing list if you feel that some of this could use a
-little more explaination.
-X
-<P>
-<UL>
-<LI><A HREF="Makefile">Makefile</A>
-<LI><A HREF="block.cpp">block.cpp</A>
-<LI><A HREF="block.h">block.h</A>
-<LI><A HREF="message_queue.cpp">message_queue.cpp</A>
-<LI><A HREF="mld.cpp">mld.cpp</A>
-<LI><A HREF="mld.h">mld.h</A>
-<LI><A HREF="task.cpp">task.cpp</A>
-<LI><A HREF="task.h">task.h</A>
-<LI><A HREF="work.cpp">work.cpp</A>
-<LI><A HREF="work.h">work.h</A>
-</UL>
-<P>
-SHAR_EOF
- $shar_touch -am 1114231398 'page08.pre' &&
- chmod 0664 'page08.pre' ||
- $echo 'restore of' 'page08.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 'page08.pre:' 'MD5 check failed'
-c035c8da307bddcab1d1031f5242aadc page08.pre
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page08.pre'`"
- test 862 -eq "$shar_count" ||
- $echo 'page08.pre:' 'original size' '862,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page02.pst ==============
-if test -f 'page02.pst' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page02.pst' '(file already exists)'
-else
- $echo 'x -' extracting 'page02.pst' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page02.pst' &&
-<HR WIDTH="100%">
-<P>
-Nothing really surprising here... Just remember that your total
-number of threads is ( ( 1 + subtasks ) * threads ). You probably
-don't want to get too carried away with that!
-<P>
-SHAR_EOF
- $shar_touch -am 1114225798 'page02.pst' &&
- chmod 0664 'page02.pst' ||
- $echo 'restore of' 'page02.pst' '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 'page02.pst:' 'MD5 check failed'
-a8c43c5c68518f6eb8c03701d1603a92 page02.pst
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page02.pst'`"
- test 204 -eq "$shar_count" ||
- $echo 'page02.pst:' 'original size' '204,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page04.pst ==============
-if test -f 'page04.pst' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page04.pst' '(file already exists)'
-else
- $echo 'x -' extracting 'page04.pst' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page04.pst' &&
-<HR WIDTH="100%">
-<P>
-One of the most difficult parts of this to get right was the Lock
-object. I didn't even have it in the beginning but I soon realized
-that the reference counts were getting weird. A little careful
-reading of the comments and the source informed me that some sort of
-locking is necessary to keep the counter sane. The simplest thing at
-that point was to use the ACE_Lock_Adaptor&lt;&gt; to adapt ACE_Mutex
-appropriately. The next trick was to ensure that the lock object was
-destroyed at the proper time to prevent both memory leaks and core
-dumps. The finaly product may be a little bit intimidating at first
-but it's really quite simple once you understand the motivation.
-<P>
-SHAR_EOF
- $shar_touch -am 1114225798 'page04.pst' &&
- chmod 0664 'page04.pst' ||
- $echo 'restore of' 'page04.pst' '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 'page04.pst:' 'MD5 check failed'
-325565f3f72961b842b612caeb93b36a page04.pst
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page04.pst'`"
- test 704 -eq "$shar_count" ||
- $echo 'page04.pst:' 'original size' '704,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page06.pst ==============
-if test -f 'page06.pst' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page06.pst' '(file already exists)'
-else
- $echo 'x -' extracting 'page06.pst' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page06.pst' &&
-<HR WIDTH="100%">
-<P>
-So you see... it wasn't really that much more complicated. We really
-just have to remember to pass to <i>next_</i> when we finish working
-on the data. If your Unit_Of_Work derivative is going to implement a
-state machine be sure that you also implement a fini() method
-<em>or</em> ensure that your chain of subtasks is large enough for all
-possible states.
-<P>
-SHAR_EOF
- $shar_touch -am 1114225798 'page06.pst' &&
- chmod 0664 'page06.pst' ||
- $echo 'restore of' 'page06.pst' '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 'page06.pst:' 'MD5 check failed'
-fb9a3381fc937578fe01ceca882df8be page06.pst
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page06.pst'`"
- test 386 -eq "$shar_count" ||
- $echo 'page06.pst:' 'original size' '386,' 'current size' "$shar_count!"
- fi
-fi
-# ============= page07.pst ==============
-if test -f 'page07.pst' && test "$first_param" != -c; then
- $echo 'x -' SKIPPING 'page07.pst' '(file already exists)'
-else
- $echo 'x -' extracting 'page07.pst' '(text)'
- sed 's/^X//' << 'SHAR_EOF' > 'page07.pst' &&
-<HR>
-<P>
-And that is that. For a more complex machine that may want to "jump
-states" you would have to set some "state information" (sorry, bad
-choice of terminology again) so that process() could decide what to do
-at each call. You might also modify Task::svc() so that it will
-respect the return value of process() and do something useful with the
-information.
-<P>
-SHAR_EOF
- $shar_touch -am 1114231398 'page07.pst' &&
- chmod 0664 'page07.pst' ||
- $echo 'restore of' 'page07.pst' '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 'page07.pst:' 'MD5 check failed'
-8d919ab7e0d5ff90e50cc785564b2f67 page07.pst
-SHAR_EOF
- else
- shar_count="`LC_ALL= LC_CTYPE= LANG= wc -c < 'page07.pst'`"
- test 371 -eq "$shar_count" ||
- $echo 'page07.pst:' 'original size' '371,' 'current size' "$shar_count!"
- fi
-fi
-rm -fr _sh05033
-exit 0
diff --git a/docs/tutorials/013/message_queue.cpp b/docs/tutorials/013/message_queue.cpp
deleted file mode 100644
index 67a22f7457b..00000000000
--- a/docs/tutorials/013/message_queue.cpp
+++ /dev/null
@@ -1,88 +0,0 @@
-
-// $Id$
-
-#include "mld.h"
-#include "task.h"
-#include "work.h"
-#include "block.h"
-
-int run_test (int iterations, int threads, int subtasks)
-{
- // Create a task with some subtasks. Each Task is a thread
- // pool of 'threads' size. If a task has a subtask, it will
- // forward the unit of work to the subtask when finished. See
- // task.{h|cpp} for more details.
- Task *task = new Task (subtasks);
-
- if (task->start (threads) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "start"), -1);
- }
-
- // Give the threads a chance to get ready.
- ACE_OS::sleep (ACE_Time_Value (1));
-
- for (int i = 0; i < iterations; ++i)
- {
- // Create a custom message block that can contain our Work object
- Message_Block *message = new Message_Block (new Work (i));
-
- // Put the "unit of work" into the message queue
- if (task->putq (message) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putq"), -1);
- }
- }
-
- // The default constructor of our custom message block will
- // insert a message telling our task to shutdown.
- Message_Block *message = new Message_Block ();
-
- // Put the shutdown request into the thread pool
- if (task->putq (message) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putq"), -1);
- }
-
- // Wait for the task to shut down. Any subtasks will also be
- // waited for.
- task->wait ();
-
- // Delete our Task to prevent a memory leak
- delete task;
-
- // Ask our memory leak detector if things are OK
- if (MLD_COUNTER != 0)
- {
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Memory Leak! (counter = %d)\n",MLD_COUNTER));
- }
-
- return (0);
-}
-
-int main (int argc, char *argv[])
-{
- // Number of Work objects to put into the Task pool
- int iterations = argc > 1 ? atoi (argv[1]) : 4;
- // Number of threads for each Task
- int threads = argc > 2 ? atoi (argv[2]) : 2;
- // Number of tasks to chain after the primary task
- int subtasks = argc > 3 ? atoi (argv[3]) : 1;
-
- (void) run_test (iterations, threads, subtasks);
-
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Application exiting\n"));
-
- return (0);
-}
-#if defined (ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION)
-template class ACE_Guard < ACE_Mutex >;
-template class ACE_Lock_Adapter < ACE_Mutex >;
-template class ACE_Atomic_Op < ACE_Mutex, int >;
-#elif defined (ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA)
-#pragma instantiate ACE_Guard<ACE_Mutex>;
-#pragma instantiate ACE_Lock_Adapter<ACE_Mutex>;
-#pragma instantiate ACE_Atomic_Op<ACE_Mutex, int>;
-#endif /*
- ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
- */
diff --git a/docs/tutorials/013/mld.cpp b/docs/tutorials/013/mld.cpp
deleted file mode 100644
index ca12d9eb514..00000000000
--- a/docs/tutorials/013/mld.cpp
+++ /dev/null
@@ -1,23 +0,0 @@
-
-// $Id$
-
-#include "mld.h"
-
-ACE_Atomic_Op < ACE_Mutex, int >mld::counter_ (0);
-
-// Increment the counter when a new mld is created...
-mld::mld (void)
-{
- ++counter_;
-}
-
-// and decrement it when the object is destructed.
-mld::~mld (void)
-{
- --counter_;
-}
-
-int mld::value (void)
-{
- return counter_.value ();
-}
diff --git a/docs/tutorials/013/mld.h b/docs/tutorials/013/mld.h
deleted file mode 100644
index 015b1a77eaa..00000000000
--- a/docs/tutorials/013/mld.h
+++ /dev/null
@@ -1,49 +0,0 @@
-
-// $Id$
-
-#ifndef MLD_H
-#define MLD_H
-
-#include "ace/Synch.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/Singleton.h"
-
-/*
- This is a cheap memory leak detector. Each class I want to watch over
- contains an mld object. The mld object's ctor increments a global counter
- while the dtor decrements it. If the counter is non-zero when the program
- is ready to exit then there may be a leak.
- */
-
-class mld
-{
-public:
- mld (void);
- ~mld (void);
-
- static int value (void);
-
-protected:
- static ACE_Atomic_Op < ACE_Mutex, int >counter_;
-};
-
-// ================================================
-
-/*
- Just drop 'MLD' anywhere in your class definition to get cheap memory leak
- detection for your class.
- */
-#define MLD mld mld_
-
-/*
- Use 'MLD_COUNTER' in main() to see if things are OK.
- */
-#define MLD_COUNTER mld::value()
-
-// ================================================
-
-#endif
diff --git a/docs/tutorials/013/page01.html b/docs/tutorials/013/page01.html
deleted file mode 100644
index 38149d1ff43..00000000000
--- a/docs/tutorials/013/page01.html
+++ /dev/null
@@ -1,64 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-My intent with this tutorial was to derive from ACE_Data_Block instead
-of ACE_Message_Block so that we could leverage the reference counting
-nature of that object.
-<P>
-Along the way, I sort of got distracted... What I ended up with is a
-poor excuse for ACE_Stream that implements a simple state machine.
-<P>
-The application is built around a thread pool where the pool's svc()
-method takes work units from the message queue for processing. As
-each unit is taken from the queue, the process() method is invoked to
-do some work. The twist is that after processing the message, we
-enqueue it into another thread pool to do more work. This continues
-through a chain of thread pools until the last where the unit's fini()
-method is called for finishing up any outstanding work.
-<P>
-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
deleted file mode 100644
index 39cfd5daf5f..00000000000
--- a/docs/tutorials/013/page02.html
+++ /dev/null
@@ -1,123 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-We'll go back to our tradition of looking at main() first. The only
-change here from our "normal" thread pool is the ability to specify
-the number of subtasks for the pool. (Each subtask is another thread
-pool in the chain. I suppose I should have named that better...)
-I've still got the custom Message_Block so that, at this level, we
-don't even know about custom Data_Blocks.
-<P>
-<HR WIDTH="100%">
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#include</font> "<font color=green>mld.h</font>"
-<font color=blue>#include</font> "<font color=green>task.h</font>"
-<font color=blue>#include</font> "<font color=green>work.h</font>"
-<font color=blue>#include</font> "<font color=green>block.h</font>"
-
-int run_test (int iterations, int threads, int subtasks)
-{
- <font color=red>// Create a task with some subtasks. Each Task is a thread</font>
- <font color=red>// pool of 'threads' size. If a task has a subtask, it will</font>
- <font color=red>// forward the unit of work to the subtask when finished. See </font>
- <font color=red>// task.{h|cpp} for more details.</font>
- Task *task = new Task (subtasks);
-
- if (task->start (threads) == -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>
- <font color=#008888>ACE_OS::sleep</font> (ACE_Time_Value (1));
-
- for (int i = 0; i &lt; iterations; ++i)
- {
- <font color=red>// Create a custom message block that can contain our Work object</font>
- Message_Block *message = new Message_Block (new Work (i));
-
- <font color=red>// Put the "<font color=green>unit of work</font>" into the message queue</font>
- if (task->putq (message) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>putq</font>"), -1);
- }
- }
-
- <font color=red>// The default constructor of our custom message block will</font>
- <font color=red>// insert a message telling our task to shutdown.</font>
- Message_Block *message = new Message_Block ();
-
- <font color=red>// Put the shutdown request into the thread pool</font>
- if (task->putq (message) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>putq</font>"), -1);
- }
-
- <font color=red>// Wait for the task to shut down. Any subtasks will also be</font>
- <font color=red>// waited for.</font>
- task->wait ();
-
- <font color=red>// Delete our Task to prevent a memory leak</font>
- delete task;
-
- <font color=red>// Ask our memory leak detector if things are OK</font>
- if (MLD_COUNTER != 0)
- {
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) Memory Leak! (counter = %d)\n</font>",MLD_COUNTER));
- }
-
- return (0);
-}
-
-int main (int argc, char *argv[])
-{
- <font color=red>// Number of Work objects to put into the Task pool</font>
- int iterations = argc > 1 ? atoi (argv[1]) : 4;
- <font color=red>// Number of threads for each Task</font>
- int threads = argc > 2 ? atoi (argv[2]) : 2;
- <font color=red>// Number of tasks to chain after the primary task</font>
- int subtasks = argc > 3 ? atoi (argv[3]) : 1;
-
- (void) run_test (iterations, threads, subtasks);
-
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) Application exiting\n</font>"));
-
- return (0);
-}
-<font color=blue>#if defined</font> (<font color=purple>ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION</font>)
-template class ACE_Guard &lt; ACE_Mutex >;
-template class ACE_Lock_Adapter &lt; ACE_Mutex >;
-template class ACE_Atomic_Op &lt; ACE_Mutex, int >;
-<font color=blue>#elif defined</font> (<font color=purple>ACE_HAS_TEMPLATE_INSTANTIATION_PRAGMA</font>)
-<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Guard&lt;ACE_Mutex>;
-<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Lock_Adapter&lt;ACE_Mutex>;
-<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Atomic_Op&lt;ACE_Mutex, int>;
-<font color=blue>#endif</font> <font color=red>/*
- ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION
- */</font>
-</PRE>
-<HR WIDTH="100%">
-<P>
-Nothing really surprising here... Just remember that your total
-number of threads is ( ( 1 + subtasks ) * threads ). You probably
-don't want to get too carried away with that!
-<P>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page03.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/013/page03.html b/docs/tutorials/013/page03.html
deleted file mode 100644
index d880cf2d449..00000000000
--- a/docs/tutorials/013/page03.html
+++ /dev/null
@@ -1,125 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-I did eventually create that ACE_Data_Block derivative that I wanted.
-My purpose in doing so was to use the reference-counting
-that is provided by ACE_Data_Block and ACE_Message_Block interactions.
- When you're working with an object in a single
-thread, it's generally not so difficult to manage it's lifetime.
-That is, it doesn't tend to go out of scope or get destroyed unless
-you do it on purpose.
-<P>
-On the other hand, if you're passing data between several threads, it
-is easy to loose track of who "owns" the data at any one time. All
-too frequently, data will be deleted by one thread while another is
-still using it. Reference counting can prevent that. The rule of
-thumb is that you increment the reference count of the object when you
-hand it off to a new thread. You then decrement the count when you're
-done with the object and let the object delete itself when there are
-no more references.
-<P>
-To prove that all of that works correctly in the tutorial, I've
-created a cheap Memory Leak Detector object. All mld instances
-reference a thread-safe counter that is incremented when the mld is
-constructed and decremented when destructed. I then insert an mld
-into each of my dynamically created objects. If I get to the end of
-main() and the counter isn't zero then I either didn't delete enough
-or I deleted too many times.
-<P>
-Simple, cheap, effective.
-<P>
-<HR WIDTH="100%">
-<HR width=50%><P><center>mld.h</center><HR width=50%>
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#ifndef</font> <font color=purple>MLD_H</font>
-<font color=blue>#define</font> <font color=purple>MLD_H</font>
-
-<font color=blue>#include</font> "<A HREF="../../../ace/Synch.h">ace/Synch.h</A>"
-
-<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
-<font color=blue># pragma</font> <font color=purple>once</font>
-<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
-
-<font color=blue>#include</font> "<A HREF="../../../ace/Singleton.h">ace/Singleton.h</A>"
-
-<font color=red>/*
- This is a cheap memory leak detector. Each class I want to watch over
- contains an mld object. The mld object's ctor increments a global counter
- while the dtor decrements it. If the counter is non-zero when the program
- is ready to exit then there may be a leak.
- */</font>
-
-class mld
-{
-public:
- mld (void);
- ~mld (void);
-
- static int value (void);
-
-protected:
- static ACE_Atomic_Op &lt; ACE_Mutex, int >counter_;
-};
-
-<font color=red>// ================================================</font>
-
-<font color=red>/*
- Just drop 'MLD' anywhere in your class definition to get cheap memory leak
- detection for your class.
- */</font>
-<font color=blue>#define</font> <font color=purple>MLD</font> mld mld_
-
-<font color=red>/*
- Use 'MLD_COUNTER' in main() to see if things are OK.
- */</font>
-<font color=blue>#define</font> <font color=purple>MLD_COUNTER</font> <font color=#008888>mld::value</font>()
-
-<font color=red>// ================================================</font>
-
-<font color=blue>#endif</font>
-</PRE>
-<HR width=50%><P><center>mld.cpp</center><HR width=50%>
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#include</font> "<font color=green>mld.h</font>"
-
-ACE_Atomic_Op &lt; ACE_Mutex, int ><font color=#008888>mld::counter_</font> (0);
-
-<font color=red>// Increment the counter when a new mld is created...</font>
-<font color=#008888>mld::mld</font> (void)
-{
- ++counter_;
-}
-
-<font color=red>// and decrement it when the object is destructed.</font>
-<font color=#008888>mld::~mld</font> (void)
-{
- --counter_;
-}
-
-int <font color=#008888>mld::value</font> (void)
-{
- return counter_.value ();
-}
-</PRE>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page04.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/013/page04.html b/docs/tutorials/013/page04.html
deleted file mode 100644
index 5660a8675cb..00000000000
--- a/docs/tutorials/013/page04.html
+++ /dev/null
@@ -1,140 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-Let's look now at the changes to our ACE_Message_Block derivative and
-the new ACE_Data_Block derivative.
-<P>
-The important thing to remember is that the data block (not the
-message block) is reference counted. When you instantiate a new
-ACE_Message_Block, it will create one or more ACE_Data_Block objects
-to contain the data you need. Optionally, you can provide it with a
-pointer to a data block.
-<P>
-When you finish with a message block, you should use the release()
-method to make it go away. Do not ever <em>delete</em> an instance of
-a message block! When you invoke release(), the message block will
-invoke release() on the data block(s) it contains. If the block's
-reference count goes to zero as a result then the block will <em>delete</em>
-itself.
-<P>
-To increment the reference count of a data block, use the
-duplicate() method of the message block (or blocks) to get a new
-message block referencing the same data block. This is very efficient
-since the actual data is not copied.
-<P>
-<HR WIDTH="100%">
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#ifndef</font> <font color=purple>BLOCK_H</font>
-<font color=blue>#define</font> <font color=purple>BLOCK_H</font>
-
-<font color=blue>#include</font> "<A HREF="../../../ace/Message_Block.h">ace/Message_Block.h</A>"
-
-<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
-<font color=blue># pragma</font> <font color=purple>once</font>
-<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
-
-<font color=blue>#include</font> "<A HREF="../../../ace/Synch.h">ace/Synch.h</A>"
-<font color=blue>#include</font> "<font color=green>mld.h</font>"
-<font color=blue>#include</font> "<font color=green>work.h</font>"
-
-<font color=red>/*
- In this Tutorial, we derive from ACE_Data_Block for our special data. With
- the possiblilty that our Task object may forward the unit of work on to
- another thread pool, we have to make sure that the data object doesn't go
- out of scope unexpectedly. An ACE_Message_Block will be deleted as soon as
- it's release() method is called but the ACE_Data_Blocks it uses are
- reference counted and only delete when the last reference release()es the
- block. We use that trait to simplify our object memory management.
- */</font>
-class Data_Block : public ACE_Data_Block
-{
-public:
- typedef ACE_Data_Block inherited;
-
- <font color=red>// Create a data block with a unit of work to be done</font>
- Data_Block (Unit_Of_Work * _data);
-
- ~Data_Block (void);
-
- <font color=red>// Returns the work pointer</font>
- Unit_Of_Work *data (void);
-
-protected:
- Unit_Of_Work * data_;
- MLD; <font color=red>// Our memory leak detector</font>
-
- <font color=red>// The ACE_Data_Block allows us to choose a locking strategy</font>
- <font color=red>// for making the reference counting thread-safe. The</font>
- <font color=red>// ACE_Lock_Adaptor&lt;> template adapts the interface of a</font>
- <font color=red>// number of lock objects so that the ACE_Message_Block will</font>
- <font color=red>// have an interface it can use.</font>
- class Lock : public ACE_Lock_Adapter &lt; ACE_Mutex >
- {
- public:
- typedef ACE_Lock_Adapter &lt; ACE_Mutex > inherited;
-
- Lock (void);
- ~Lock (void);
-
- <font color=red>// destroy() will be called to explicitly delete the</font>
- <font color=red>// lock when we no longer need it. The method will then</font>
- <font color=red>// cleanup to prevent any memory leaks.</font>
- int destroy (void);
-
- protected:
- MLD;
- };
-};
-
-<font color=red>/*
- This simple derivative of ACE_Message_Block will construct our Data_Block
- object to contain a unit of work.
- */</font>
-class Message_Block : public ACE_Message_Block
-{
-public:
- typedef ACE_Message_Block inherited;
-
- Message_Block (void);
- Message_Block (Unit_Of_Work * _data);
-
- ~Message_Block (void);
-
-protected:
- MLD;
-};
-
-<font color=blue>#endif</font>
-</PRE>
-<HR WIDTH="100%">
-<P>
-One of the most difficult parts of this to get right was the Lock
-object. I didn't even have it in the beginning but I soon realized
-that the reference counts were getting weird. A little careful
-reading of the comments and the source informed me that some sort of
-locking is necessary to keep the counter sane. The simplest thing at
-that point was to use the ACE_Lock_Adaptor&lt;&gt; to adapt ACE_Mutex
-appropriately. The next trick was to ensure that the lock object was
-destroyed at the proper time to prevent both memory leaks and core
-dumps. The finaly product may be a little bit intimidating at first
-but it's really quite simple once you understand the motivation.
-<P>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page05.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/013/page05.html b/docs/tutorials/013/page05.html
deleted file mode 100644
index 48e9742f864..00000000000
--- a/docs/tutorials/013/page05.html
+++ /dev/null
@@ -1,108 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-On this page we have the code for the Data_Block and Message_Block
-objects. As you probably suspect from the header on the previous
-page, the complicated part is in the construction and destruction of
-the Data_Block.
-<P>
-<HR WIDTH="100%">
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#include</font> "<font color=green>block.h</font>"
-
-<font color=red>/*
- Construct a Dat_Block to contain a unit of work. Note the careful
- construction of the baseclass to set the block type and the locking
- strategy.
- */</font>
-<font color=#008888>Data_Block::Data_Block</font> (Unit_Of_Work * _data)
- : ACE_Data_Block (0, <font color=#008888>ACE_Message_Block::MB_DATA</font>, 0, 0, new Lock (), 0, 0)
- ,data_ (_data)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Data_Block ctor for 0x%x\n</font>", (void *) this, (void *) data_));
-}
-
-<font color=red>/*
- The Lock object created in the constructor is stored in the baseclass and
- available through the locking_strategy() method. We can cast it's value to
- our Lock object and invoke the destroy() to indicate that we want it to go
- away when the lock is released.
- */</font>
-<font color=#008888>Data_Block::~Data_Block</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Data_Block dtor for 0x%x\n</font>", (void *) this, (void *) data_));
- ((Lock *) locking_strategy ())->destroy ();
- delete data_;
-}
-
-<font color=red>/*
- Return the data
- */</font>
-Unit_Of_Work *<font color=#008888>Data_Block::data</font> (void)
-{
- return this->data_;
-}
-
-Data_Block:: <font color=#008888>Lock::Lock</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Lock ctor\n</font>", (void *) this));
-}
-
-Data_Block:: <font color=#008888>Lock::~Lock</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Lock dtor\n</font>", (void *) this));
-}
-
-<font color=red>/*
- Delete ourselves to prevent any memory leak
- */</font>
-int <font color=#008888>Data_Block::Lock</font>::destroy (void)
-{
- delete this;
- return (0);
-}
-
-<font color=red>/*
- Create an baseclass unit of work when we instantiate a hangup message.
- */</font>
-<font color=#008888>Message_Block::Message_Block</font> (void)
- :ACE_Message_Block (new Data_Block (new Unit_Of_Work ()))
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Message_Block ctor for shutdown\n</font>", (void *) this));
- this->msg_type (MB_HANGUP);
-}
-
-<font color=red>/*
- Store the unit of work in a Data_Block and initialize the baseclass with
- that data.
- */</font>
-<font color=#008888>Message_Block::Message_Block</font> (Unit_Of_Work * _data)
- :ACE_Message_Block (new Data_Block (_data))
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Message_Block ctor for 0x%x\n</font>", (void *) this, (void *) _data));
-}
-
-<font color=#008888>Message_Block::~Message_Block</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Message_Block dtor\n</font>", (void *) this));
-}
-</PRE>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page06.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/013/page06.html b/docs/tutorials/013/page06.html
deleted file mode 100644
index d6ef1d7270e..00000000000
--- a/docs/tutorials/013/page06.html
+++ /dev/null
@@ -1,303 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-Let's take a look now at the new Task object. This will obviously be
-different from the Tasks we've created before but I think you'll be
-surprised at how relatively simple it actually is.
-<P>
-Remember that the goal of this tutorial was to use the reference
-counting abilities of the ACE_Data_Block. The only way to show that
-effectively is to have a data block passed between different threads.
-A thread pool isn't really going to do that so, instead, our new Task
-can be part of a chain of tasks. In that way, each Task can pass the
-data on to another and satisfy our need for moving the ACE_Data_Block
-around.
-If we've done the reference counting correctly then none of our tasks
-will be trying to work with deleted data and we won't have any memory
-leaks at the end.
-<P>
-There's not much to the header, so I've included it and the cpp file
-on this one page.
-<P>
-<HR WIDTH="100%">
-<HR width=50%><P><center>task.h</center><HR width=50%>
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#ifndef</font> <font color=purple>TASK_H</font>
-<font color=blue>#define</font> <font color=purple>TASK_H</font>
-
-<font color=blue>#include</font> "<A HREF="../../../ace/Task.h">ace/Task.h</A>"
-
-<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
-<font color=blue># pragma</font> <font color=purple>once</font>
-<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
-
-<font color=blue>#include</font> "<font color=green>mld.h</font>"
-
-<font color=red>/*
- This is much like the Task we've used in the past for implementing a thread
- pool. This time, however, I've made the Task an element in a singly-linked
- list. As the svc() method finishes the process() on a unit of work, it
- will enqueue that unit of work to the next_ Task if there is one. If the
- Task does not have a next_ Task, it will invoke the unit of work object's
- fini() method after invoking process().
- */</font>
-class Task : public ACE_Task &lt; ACE_MT_SYNCH >
-{
-public:
-
- typedef ACE_Task &lt; ACE_MT_SYNCH > inherited;
-
- <font color=red>// Construct ourselves and an optional number of subtasks</font>
- <font color=red>// chained beyond us.</font>
- Task (int sub_tasks = 0);
- ~Task (void);
-
- <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>
- int svc (void);
-
- <font color=red>// Shut down the thread pool and it's associated subtasks</font>
- int close (u_long flags = 0);
-
- <font color=red>// Wait for the pool and subtasks to close</font>
- int wait (void);
-
-protected:
- ACE_Barrier * barrier_;
- Task *next_;
- MLD;
-};
-
-<font color=blue>#endif</font>
-</PRE>
-<HR width=50%><P><center>task.cpp</center><HR width=50%>
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#include</font> "<font color=green>task.h</font>"
-<font color=blue>#include</font> "<font color=green>block.h</font>"
-<font color=blue>#include</font> "<font color=green>work.h</font>"
-
-<font color=red>/*
- Construct the Task with zero or more subtasks. If subtasks are requested,
- we assign our next_ pointer to the first of those and let it worry about
- any remaining subtasks.
- */</font>
-<font color=#008888>Task::Task</font> (int sub_tasks)
- : barrier_ (0)
- ,next_ (0)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) Task ctor 0x%x\n</font>", (void *) this));
- if (sub_tasks)
- {
- next_ = new Task (--sub_tasks);
- }
-}
-
-<font color=red>/*
- Delete our barrier object and any subtasks we may have.
- */</font>
-<font color=#008888>Task::~Task</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) Task dtor 0x%x\n</font>", (void *) this));
-
- delete barrier_;
- delete next_;
-}
-
-<font color=red>/*
- Open our thread pool with the requested number of threads. If subtasks are
- 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::start</font> (int threads)
-{
- if (next_)
- {
- if (next_->start (threads) == -1)
- {
- return -1;
- }
- }
-
- barrier_ = new ACE_Barrier (threads);
- return this->activate (THR_NEW_LWP, threads);
-}
-
-<font color=red>/*
- Close ourselves and any subtasks. This just prints a message so that we can
- assure ourselves things are cleaned up correctly.
- */</font>
-int <font color=#008888>Task::close</font> (u_long flags)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) Task close 0x%x\n</font>", (void *) this));
- if (next_)
- {
- next_->close (flags);
- }
-
- return (0);
-}
-
-<font color=red>/*
- Wait for all of the threads in our pool to exit and then wait for any
- subtasks. When called from the front of the task chain, this won't return
- until all thread pools in the chain have exited.
- */</font>
-int <font color=#008888>Task::wait</font> (void)
-{
- <font color=#008888>inherited::wait</font> ();
- if (next_)
- {
- next_->wait ();
- }
- return (0);
-}
-
-<font color=red>/*
- Like the thread-pools before, this is where all of the work is done.
- */</font>
-int <font color=#008888>Task::svc</font> (void)
-{
- <font color=red>// Wait for all threads to get this far before continuing.</font>
- this->barrier_->wait ();
-
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) Task 0x%x starts in thread %u\n</font>", (void *) this, <font color=#008888>ACE_Thread::self</font> ()));
-
- <font color=red>// getq() wants an ACE_Message_Block so we'll start out with one</font>
- <font color=red>// of those. We could do some casting (or even auto-casting) to</font>
- <font color=red>// avoid the extra variable but I prefer to be clear about our actions.</font>
- ACE_Message_Block *message;
-
- <font color=red>// What we really put into the queue was our Message_Block.</font>
- <font color=red>// After we get the message from the queue, we'll cast it to this </font>
- <font color=red>// so that we know how to work on it.</font>
- Message_Block *message_block;
-
- <font color=red>// And, of course, our Message_Block contains our Data_Block</font>
- <font color=red>// instead of the typical ACE_Data_Block</font>
- Data_Block *data_block;
-
- <font color=red>// Even though we put Work objects into the queue, we take them</font>
- <font color=red>// out using the baseclass pointer. This allows us to create new </font>
- <font color=red>// derivatives without having to change this svc() method.</font>
- Unit_Of_Work *work;
-
- while (1)
- {
- <font color=red>// Get the ACE_Message_Block</font>
- if (this->getq (message) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>getq</font>"), -1);
- }
-
- <font color=red>// "<font color=green>Convert</font>" it to our Message_Block</font>
- message_block = (Message_Block *) message;
-
- <font color=red>// Get the ACE_Data_Block and "<font color=green>convert</font>" to Data_Block in one step.</font>
- data_block = (Data_Block *) (message_block->data_block ());
-
- <font color=red>// Get the unit of work from the data block</font>
- work = data_block->data ();
-
- <font color=red>// Show the object's instance value and "<font color=green>type name</font>"</font>
- work->who_am_i ();
- work->what_am_i ();
-
- <font color=red>// If there is a hangup we need to tell our pool-peers as</font>
- <font color=red>// well as any subtasks.</font>
- if (message_block->msg_type () == <font color=#008888>ACE_Message_Block::MB_HANGUP</font>)
- {
- <font color=red>// duplicate()ing the message block will increment the</font>
- <font color=red>// reference counts on the data blocks. This allows us</font>
- <font color=red>// to safely release() the message block. The rule of</font>
- <font color=red>// thumb is that if you pass a message block to a new</font>
- <font color=red>// owner, duplicate() it. Then you can release() when</font>
- <font color=red>// you're done and not worry about memory leaks.</font>
- if (this->putq (message_block->duplicate ()) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>putq</font>"), -1);
- }
-
- <font color=red>// If we have a subtask, duplicate() the message block</font>
- <font color=red>// again and pass it to that task's queue</font>
- if (next_ && next_->putq (message_block->duplicate ()) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>putq</font>"), -1);
- }
-
- <font color=red>// We're now done with our copy of the block, so we can</font>
- <font color=red>// release it. Our peers/subtasks have their own message </font>
- <font color=red>// block to access the shared data blocks.</font>
- message_block->release ();
-
- break;
- }
-
- <font color=red>// If this isn't a hangup/shutdown message then we tell the</font>
- <font color=red>// unit of work to process() for a while.</font>
- work->process ();
-
- if (next_)
- {
- <font color=red>// If we have subtasks, we pass the block on to them. Notice</font>
- <font color=red>// that I don't bother to duplicate() the block since I won't </font>
- <font color=red>// release it in this case. I could have invoked</font>
- <font color=red>// duplicate() in the puq() and then release()</font>
- <font color=red>// afterwards. Either is acceptable.</font>
- if (next_->putq (message_block) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>putq</font>"), -1);
- }
- else
- {
- <font color=red>// If we don't have subtasks then invoke fini() to tell</font>
- <font color=red>// the unit of work that we won't be invoking process()</font>
- <font color=red>// any more. Then release() the block. This release()</font>
- <font color=red>// would not change if we duplicate()ed in the above conditional</font>
- work->fini ();
- message_block->release ();
- }
-
- <font color=red>// Pretend that the work takes some time...</font>
- <font color=#008888>ACE_OS::sleep</font> (ACE_Time_Value (0, 250));
- }
-
- return (0);
-}
-</PRE>
-<HR WIDTH="100%">
-<P>
-So you see... it wasn't really that much more complicated. We really
-just have to remember to pass to <i>next_</i> when we finish working
-on the data. If your Unit_Of_Work derivative is going to implement a
-state machine be sure that you also implement a fini() method
-<em>or</em> ensure that your chain of subtasks is large enough for all
-possible states.
-<P>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page07.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/013/page07.html b/docs/tutorials/013/page07.html
deleted file mode 100644
index d2e22b2bdde..00000000000
--- a/docs/tutorials/013/page07.html
+++ /dev/null
@@ -1,257 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-I've been trying to justify the chain of tasks by talking about a
-Work object that implements a state machine. The idea is that your
-Work object has to perform a series of discrete steps to complete it's
-function. Traditionally, all of those steps would take place in one
-thread of execution. That thread would probably be one from a Task
-thread pool.
-<P>
-Suppose, however, that some of those steps spend a lot of time waiting
-for disk IO. You could find that all of your thread-pool threads
-are just sitting there waiting for the disk. You might then be
-tempted to increase the thread pool size to get more work through.
-However, if some of the stages are memory intensive, you could run out
-of memory if all of the workers get to that state at the same time.
-<P>
-One solution might be to have different thread pools for each state.
-Each pool could have it's size tuned appropriately for the work that
-would be done there. That's where the chain of Tasks comes in.
- In this tutorial's implementation I've taken the
-easy route and set all of the thread pools to the same size but a more
-realistic solution would be to set each thread pool in the chain to a
-specific size as needed by that state of operation.
-<P>
-There's not much to this header either so I've combined it with the
-cpp file as with task.
-<P>
-<HR WIDTH="100%">
-<HR width=50%><P><center>work.h</center><HR width=50%>
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#ifndef</font> <font color=purple>WORK_H</font>
-<font color=blue>#define</font> <font color=purple>WORK_H</font>
-
-<font color=blue>#include</font> "<A HREF="../../../ace/Log_Msg.h">ace/Log_Msg.h</A>"
-
-<font color=blue>#if !defined</font> (<font color=purple>ACE_LACKS_PRAGMA_ONCE</font>)
-<font color=blue># pragma</font> <font color=purple>once</font>
-<font color=blue>#endif</font> <font color=red>/* ACE_LACKS_PRAGMA_ONCE */</font>
-
-<font color=blue>#include</font> "<A HREF="../../../ace/Synch.h">ace/Synch.h</A>"
-<font color=blue>#include</font> "<font color=green>mld.h</font>"
-
-<font color=red>/*
- Our specilized message queue and thread pool will know how to do "<font color=green>work</font>" on
- our Unit_Of_Work baseclass.
- */</font>
-class Unit_Of_Work
-{
-public:
- Unit_Of_Work (void);
-
- virtual ~ Unit_Of_Work (void);
-
- <font color=red>// Display the object instance value</font>
- void who_am_i (void);
-
- <font color=red>// The baseclass can override this to show it's "<font color=green>type name</font>"</font>
- virtual void what_am_i (void);
-
- <font color=red>// This is where you do application level logic. It will be</font>
- <font color=red>// called once for each thread pool it passes through. It</font>
- <font color=red>// would typically implement a state machine and execute a</font>
- <font color=red>// different state on each call.</font>
- virtual int process (void);
-
- <font color=red>// This is called by the last Task in the series (see task.h)</font>
- <font color=red>// in case our process() didn't get through all of it's states.</font>
- virtual int fini (void);
-
-protected:
- ACE_Atomic_Op &lt; ACE_Mutex, int >state_;
- MLD;
-};
-
-<font color=red>/*
- A fairly trivial work derivative that implements an equally trivial state
- machine in process()
- */</font>
-class Work : public Unit_Of_Work
-{
-public:
- Work (void);
-
- Work (int message);
-
- virtual ~ Work (void);
-
- void what_am_i (void);
-
- int process (void);
-
- int fini (void);
-
-protected:
- int message_;
- MLD;
-};
-
-<font color=blue>#endif</font>
-</PRE>
-<HR width=50%><P><center>work.cpp</center><HR width=50%>
-<PRE>
-
-<font color=red>// $Id$</font>
-
-<font color=blue>#include</font> "<font color=green>work.h</font>"
-
-<font color=red>/*
- Initialize the state to zero
- */</font>
-<font color=#008888>Unit_Of_Work::Unit_Of_Work</font> (void)
- : state_ (0)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Unit_Of_Work ctor\n</font>", (void *) this));
-}
-
-<font color=#008888>Unit_Of_Work::~Unit_Of_Work</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Unit_Of_Work dtor\n</font>", (void *) this));
-}
-
-<font color=red>/*
- Display our instance value
- */</font>
-void <font color=#008888>Unit_Of_Work::who_am_i</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Unit_Of_Work instance\n</font>", (void *) this));
-}
-
-<font color=red>/*
- Dispay our type name
- */</font>
-void <font color=#008888>Unit_Of_Work::what_am_i</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x I am a Unit_Of_Work object\n</font>", (void *) this));
-}
-
-<font color=red>/*
- Return failure. You should always derive from Unit_Of_Work...
- */</font>
-int <font color=#008888>Unit_Of_Work::process</font> (void)
-{
- return -1;
-}
-
-<font color=red>/*
- ditto
- */</font>
-int <font color=#008888>Unit_Of_Work::fini</font> (void)
-{
- return -1;
-}
-
-<font color=red>/*
- Default constructor has no "<font color=green>message number</font>"
- */</font>
-<font color=#008888>Work::Work</font> (void)
- :message_ (-1)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Work ctor\n</font>", (void *) this));
-}
-
-<font color=red>/*
- The useful constructor remembers which message it is and will tell you if
- you ask.
- */</font>
-<font color=#008888>Work::Work</font> (int message)
- : message_ (message)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Work ctor for message %d\n</font>", (void *) this, message_));
-}
-
-<font color=#008888>Work::~Work</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Work dtor\n</font>", (void *) this));
-}
-
-<font color=red>/*
- This objects type name is different from the baseclass
- */</font>
-void <font color=#008888>Work::what_am_i</font> (void)
-{
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x I am a Work object for message %d\n</font>", (void *) this, message_));
-}
-
-<font color=red>/*
- A very simple state machine that just walks through three stages. If it is
- called more than that, it will tell you not to bother.
- */</font>
-int <font color=#008888>Work::process</font> (void)
-{
- switch (++state_)
- {
- case 1:
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Stage One\n</font>", (void *) this));
- break;
- case 2:
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Stage Two\n</font>", (void *) this));
- break;
- case 3:
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x Stage Three\n</font>", (void *) this));
- break;
- default:
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x No work to do in state %d\n</font>",
- (void *) this, state_.value ()));
- break;
- }
- return (0);
-}
-
-<font color=red>/*
- If you don't have enough subtasks in the chain then the state machine won't
- progress to the end. The fini() hook will allow us to recover from that by
- executing the remaining states in the final task of the chain.
- */</font>
-int <font color=#008888>Work::fini</font> (void)
-{
- while (state_.value () &lt; 3)
- {
- ACE_DEBUG ((LM_DEBUG, "<font color=green>(%P|%t) 0x%x <font color=#008888>Work::fini</font>() state %d\n</font>", (void *) this,state_.value()));
- if (this->process () == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "<font color=green>%p\n</font>", "<font color=green>process</font>"), -1);
- }
- }
- return (0);
-}
-</PRE>
-<HR>
-<P>
-And that is that. For a more complex machine that may want to "jump
-states" you would have to set some "state information" (sorry, bad
-choice of terminology again) so that process() could decide what to do
-at each call. You might also modify Task::svc() so that it will
-respect the return value of process() and do something useful with the
-information.
-<P>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page08.html">Continue This Tutorial</A>]</CENTER>
diff --git a/docs/tutorials/013/page08.html b/docs/tutorials/013/page08.html
deleted file mode 100644
index ebede97f796..00000000000
--- a/docs/tutorials/013/page08.html
+++ /dev/null
@@ -1,42 +0,0 @@
-<!-- $Id$ -->
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 013</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<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>
-And that's the end of another tutorial. This one is probably the most
-complicated so far because I've introduced or expanded upon
-a number of different
-concepts. Namely: state machines, reference counting and task
-chaining. I hope I didn't complicate things to the point where the
-lesson got lost in the noise. As always, feel free to drop a note to
-the ACE-Users mailing list if you feel that some of this could use a
-little more explaination.
-
-<P>
-<UL>
-<LI><A HREF="Makefile">Makefile</A>
-<LI><A HREF="block.cpp">block.cpp</A>
-<LI><A HREF="block.h">block.h</A>
-<LI><A HREF="message_queue.cpp">message_queue.cpp</A>
-<LI><A HREF="mld.cpp">mld.cpp</A>
-<LI><A HREF="mld.h">mld.h</A>
-<LI><A HREF="task.cpp">task.cpp</A>
-<LI><A HREF="task.h">task.h</A>
-<LI><A HREF="work.cpp">work.cpp</A>
-<LI><A HREF="work.h">work.h</A>
-</UL>
-<P>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] </CENTER>
diff --git a/docs/tutorials/013/task.cpp b/docs/tutorials/013/task.cpp
deleted file mode 100644
index 37af6f8072f..00000000000
--- a/docs/tutorials/013/task.cpp
+++ /dev/null
@@ -1,193 +0,0 @@
-
-// $Id$
-
-#include "task.h"
-#include "block.h"
-#include "work.h"
-
-/*
- Construct the Task with zero or more subtasks. If subtasks are requested,
- we assign our next_ pointer to the first of those and let it worry about
- any remaining subtasks.
- */
-Task::Task (int sub_tasks)
- : barrier_ (0)
- ,next_ (0)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Task ctor 0x%x\n", (void *) this));
- if (sub_tasks)
- {
- next_ = new Task (--sub_tasks);
- }
-}
-
-/*
- Delete our barrier object and any subtasks we may have.
- */
-Task::~Task (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Task dtor 0x%x\n", (void *) this));
-
- delete barrier_;
- delete next_;
-}
-
-/*
- Open our thread pool with the requested number of threads. If subtasks are
- enabled, they inherit the thread-pool size. Make sure that the subtasks can
- be opened before we open our own threadpool.
- */
-int Task::start (int threads)
-{
- if (next_)
- {
- if (next_->start (threads) == -1)
- {
- return -1;
- }
- }
-
- barrier_ = new ACE_Barrier (threads);
- return this->activate (THR_NEW_LWP, threads);
-}
-
-/*
- Close ourselves and any subtasks. This just prints a message so that we can
- assure ourselves things are cleaned up correctly.
- */
-int Task::close (u_long flags)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Task close 0x%x\n", (void *) this));
- if (next_)
- {
- next_->close (flags);
- }
-
- return (0);
-}
-
-/*
- Wait for all of the threads in our pool to exit and then wait for any
- subtasks. When called from the front of the task chain, this won't return
- until all thread pools in the chain have exited.
- */
-int Task::wait (void)
-{
- inherited::wait ();
- if (next_)
- {
- next_->wait ();
- }
- return (0);
-}
-
-/*
- Like the thread-pools before, this is where all of the work is done.
- */
-int Task::svc (void)
-{
- // Wait for all threads to get this far before continuing.
- this->barrier_->wait ();
-
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) Task 0x%x starts in thread %u\n", (void *) this, ACE_Thread::self ()));
-
- // getq() wants an ACE_Message_Block so we'll start out with one
- // of those. We could do some casting (or even auto-casting) to
- // avoid the extra variable but I prefer to be clear about our actions.
- ACE_Message_Block *message;
-
- // What we really put into the queue was our Message_Block.
- // After we get the message from the queue, we'll cast it to this
- // so that we know how to work on it.
- Message_Block *message_block;
-
- // And, of course, our Message_Block contains our Data_Block
- // instead of the typical ACE_Data_Block
- Data_Block *data_block;
-
- // Even though we put Work objects into the queue, we take them
- // out using the baseclass pointer. This allows us to create new
- // derivatives without having to change this svc() method.
- Unit_Of_Work *work;
-
- while (1)
- {
- // Get the ACE_Message_Block
- if (this->getq (message) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "getq"), -1);
- }
-
- // "Convert" it to our Message_Block
- message_block = (Message_Block *) message;
-
- // Get the ACE_Data_Block and "convert" to Data_Block in one step.
- data_block = (Data_Block *) (message_block->data_block ());
-
- // Get the unit of work from the data block
- work = data_block->data ();
-
- // Show the object's instance value and "type name"
- work->who_am_i ();
- work->what_am_i ();
-
- // If there is a hangup we need to tell our pool-peers as
- // well as any subtasks.
- if (message_block->msg_type () == ACE_Message_Block::MB_HANGUP)
- {
- // duplicate()ing the message block will increment the
- // reference counts on the data blocks. This allows us
- // to safely release() the message block. The rule of
- // thumb is that if you pass a message block to a new
- // owner, duplicate() it. Then you can release() when
- // you're done and not worry about memory leaks.
- if (this->putq (message_block->duplicate ()) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putq"), -1);
- }
-
- // If we have a subtask, duplicate() the message block
- // again and pass it to that task's queue
- if (next_ && next_->putq (message_block->duplicate ()) == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putq"), -1);
- }
-
- // We're now done with our copy of the block, so we can
- // release it. Our peers/subtasks have their own message
- // block to access the shared data blocks.
- message_block->release ();
-
- break;
- }
-
- // If this isn't a hangup/shutdown message then we tell the
- // unit of work to process() for a while.
- work->process ();
-
- if (next_)
- {
- // If we have subtasks, we pass the block on to them. Notice
- // that I don't bother to duplicate() the block since I won't
- // release it in this case. I could have invoked
- // duplicate() in the puq() and then release()
- // afterwards. Either is acceptable.
- if (next_->putq (message_block) == -1)
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "putq"), -1);
- }
- else
- {
- // If we don't have subtasks then invoke fini() to tell
- // the unit of work that we won't be invoking process()
- // any more. Then release() the block. This release()
- // would not change if we duplicate()ed in the above conditional
- work->fini ();
- message_block->release ();
- }
-
- // Pretend that the work takes some time...
- ACE_OS::sleep (ACE_Time_Value (0, 250));
- }
-
- return (0);
-}
diff --git a/docs/tutorials/013/task.h b/docs/tutorials/013/task.h
deleted file mode 100644
index c111333b022..00000000000
--- a/docs/tutorials/013/task.h
+++ /dev/null
@@ -1,57 +0,0 @@
-
-// $Id$
-
-#ifndef TASK_H
-#define TASK_H
-
-#include "ace/Task.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "mld.h"
-
-/*
- This is much like the Task we've used in the past for implementing a thread
- pool. This time, however, I've made the Task an element in a singly-linked
- list. As the svc() method finishes the process() on a unit of work, it
- will enqueue that unit of work to the next_ Task if there is one. If the
- Task does not have a next_ Task, it will invoke the unit of work object's
- fini() method after invoking process().
- */
-class Task : public ACE_Task < ACE_MT_SYNCH >
-{
-public:
-
- typedef ACE_Task < ACE_MT_SYNCH > inherited;
-
- // Construct ourselves and an optional number of subtasks
- // chained beyond us.
- Task (int sub_tasks = 0);
- ~Task (void);
-
- /*
- 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.
- int svc (void);
-
- // Shut down the thread pool and it's associated subtasks
- int close (u_long flags = 0);
-
- // Wait for the pool and subtasks to close
- int wait (void);
-
-protected:
- ACE_Barrier * barrier_;
- Task *next_;
- MLD;
-};
-
-#endif
diff --git a/docs/tutorials/013/work.cpp b/docs/tutorials/013/work.cpp
deleted file mode 100644
index ac2920fec90..00000000000
--- a/docs/tutorials/013/work.cpp
+++ /dev/null
@@ -1,125 +0,0 @@
-
-// $Id$
-
-#include "work.h"
-
-/*
- Initialize the state to zero
- */
-Unit_Of_Work::Unit_Of_Work (void)
- : state_ (0)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Unit_Of_Work ctor\n", (void *) this));
-}
-
-Unit_Of_Work::~Unit_Of_Work (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Unit_Of_Work dtor\n", (void *) this));
-}
-
-/*
- Display our instance value
- */
-void Unit_Of_Work::who_am_i (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Unit_Of_Work instance\n", (void *) this));
-}
-
-/*
- Dispay our type name
- */
-void Unit_Of_Work::what_am_i (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x I am a Unit_Of_Work object\n", (void *) this));
-}
-
-/*
- Return failure. You should always derive from Unit_Of_Work...
- */
-int Unit_Of_Work::process (void)
-{
- return -1;
-}
-
-/*
- ditto
- */
-int Unit_Of_Work::fini (void)
-{
- return -1;
-}
-
-/*
- Default constructor has no "message number"
- */
-Work::Work (void)
- :message_ (-1)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Work ctor\n", (void *) this));
-}
-
-/*
- The useful constructor remembers which message it is and will tell you if
- you ask.
- */
-Work::Work (int message)
- : message_ (message)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Work ctor for message %d\n", (void *) this, message_));
-}
-
-Work::~Work (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Work dtor\n", (void *) this));
-}
-
-/*
- This objects type name is different from the baseclass
- */
-void Work::what_am_i (void)
-{
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x I am a Work object for message %d\n", (void *) this, message_));
-}
-
-/*
- A very simple state machine that just walks through three stages. If it is
- called more than that, it will tell you not to bother.
- */
-int Work::process (void)
-{
- switch (++state_)
- {
- case 1:
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Stage One\n", (void *) this));
- break;
- case 2:
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Stage Two\n", (void *) this));
- break;
- case 3:
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Stage Three\n", (void *) this));
- break;
- default:
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x No work to do in state %d\n",
- (void *) this, state_.value ()));
- break;
- }
- return (0);
-}
-
-/*
- If you don't have enough subtasks in the chain then the state machine won't
- progress to the end. The fini() hook will allow us to recover from that by
- executing the remaining states in the final task of the chain.
- */
-int Work::fini (void)
-{
- while (state_.value () < 3)
- {
- ACE_DEBUG ((LM_DEBUG, "(%P|%t) 0x%x Work::fini() state %d\n", (void *) this,state_.value()));
- if (this->process () == -1)
- {
- ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "process"), -1);
- }
- }
- return (0);
-}
diff --git a/docs/tutorials/013/work.h b/docs/tutorials/013/work.h
deleted file mode 100644
index bdd0835e098..00000000000
--- a/docs/tutorials/013/work.h
+++ /dev/null
@@ -1,72 +0,0 @@
-
-// $Id$
-
-#ifndef WORK_H
-#define WORK_H
-
-#include "ace/Log_Msg.h"
-
-#if !defined (ACE_LACKS_PRAGMA_ONCE)
-# pragma once
-#endif /* ACE_LACKS_PRAGMA_ONCE */
-
-#include "ace/Synch.h"
-#include "mld.h"
-
-/*
- Our specilized message queue and thread pool will know how to do "work" on
- our Unit_Of_Work baseclass.
- */
-class Unit_Of_Work
-{
-public:
- Unit_Of_Work (void);
-
- virtual ~ Unit_Of_Work (void);
-
- // Display the object instance value
- void who_am_i (void);
-
- // The baseclass can override this to show it's "type name"
- virtual void what_am_i (void);
-
- // This is where you do application level logic. It will be
- // called once for each thread pool it passes through. It
- // would typically implement a state machine and execute a
- // different state on each call.
- virtual int process (void);
-
- // This is called by the last Task in the series (see task.h)
- // in case our process() didn't get through all of it's states.
- virtual int fini (void);
-
-protected:
- ACE_Atomic_Op < ACE_Mutex, int >state_;
- MLD;
-};
-
-/*
- A fairly trivial work derivative that implements an equally trivial state
- machine in process()
- */
-class Work : public Unit_Of_Work
-{
-public:
- Work (void);
-
- Work (int message);
-
- virtual ~ Work (void);
-
- void what_am_i (void);
-
- int process (void);
-
- int fini (void);
-
-protected:
- int message_;
- MLD;
-};
-
-#endif