summaryrefslogtreecommitdiff
path: root/docs/tutorials/021/page05.html
diff options
context:
space:
mode:
Diffstat (limited to 'docs/tutorials/021/page05.html')
-rw-r--r--docs/tutorials/021/page05.html91
1 files changed, 0 insertions, 91 deletions
diff --git a/docs/tutorials/021/page05.html b/docs/tutorials/021/page05.html
deleted file mode 100644
index 6e238fcc85b..00000000000
--- a/docs/tutorials/021/page05.html
+++ /dev/null
@@ -1,91 +0,0 @@
-<HTML>
-<HEAD>
- <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
- <META NAME="Author" CONTENT="James CE Johnson">
- <TITLE>ACE Tutorial 021</TITLE>
-</HEAD>
-<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
-
-<CENTER><B><FONT SIZE=+2>ACE Tutorial 021</FONT></B></CENTER>
-
-<CENTER><B><FONT SIZE=+2>Pooling your memories</FONT></B></CENTER>
-
-<P>
-<HR WIDTH="100%">
- Everything common the server & client is kept here. In
- particular, the Constants class where we keep the names &
- semaphore keys.
- <p>
- The Allocator class is just a thin wrapper around
- ACE_Malloc&lt;&gt; that moves some of the details out of the
- application logic.
-<hr><PRE>
-
-<font color=red>// $Id$ </font>
-
-<font color=blue>#include</font> "<font color=green>mpool.h</font>"
-
-<font color=red>/*
- Set the values of all of the constants. This guarantees that client
- and server don't get confused.
- */</font>
-const int <font color=#008888>Constants::SEM_KEY_1</font> = ACE_DEFAULT_SEM_KEY + 1;
-const int <font color=#008888>Constants::SEM_KEY_2</font> = ACE_DEFAULT_SEM_KEY + 2;
-
-const int <font color=#008888>Constants::SHMSZ</font> = 27;
-const char * <font color=#008888>Constants::SHMDATA</font> = "<font color=green>abcdefghijklmnopqrstuvwxyz</font>";
-
-const char * <font color=#008888>Constants::PoolName</font> = "<font color=green>SharedMemoryPool</font>";
-const char * <font color=#008888>Constants::RegionName</font> = "<font color=green>Alphabet</font>";
-
-<font color=red>/*
- We have to create a copy of the _name parameter in case the caller
- has dynamically allocated it. The pool_ is set to NULL & will be
- allocated by the accessor.
- */</font>
-<font color=#008888>Allocator::Allocator</font>( const char * _name )
- : name_(<font color=#008888>ACE_OS::strdup</font>(_name)),
- pool_(0)
-{
- if( ! name_ )
- {
- ACE_ERROR ((LM_ERROR, "<font color=green>(%P) %p</font>",
- "<font color=green><font color=#008888>Allocator::Allocator</font> cannot strdup pool name</font>" ));
- }
-}
-
-<font color=#008888>Allocator::~Allocator</font>(void)
-{
- <font color=red>/*
- strdup() uses malloc(), so we must use free() to clean up.
- */</font>
- if( name_ )
- {
- free(name_);
- }
-
- <font color=red>// delete doesn't really care if you give it a NULL pointer.</font>
- delete pool_;
-}
-
-<font color=red>/*
- Allocate the pool. Since we return a reference, we'll be in really
- bad shape if the new fails. This is a great place to throw an
- exception!
- The other concern is thread safety. If two threads call here at
- about the same time, we may create the pool twice. We can't use a
- Singleton because we want to have multiple Allocator instances. The
- Singleton techniques can be used though.
- */</font>
-<font color=#008888>Allocator::pool_t</font> & Allocator::pool(void)
-{
- if( ! pool_ )
- {
- pool_ = new pool_t( name_ );
- }
-
- return *pool_;
-}
-</PRE>
-<P><HR WIDTH="100%">
-<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page06.html">Continue This Tutorial</A>]</CENTER>