~ubuntu-branches/ubuntu/breezy/ace/breezy

« back to all changes in this revision

Viewing changes to docs/tutorials/006/page01.html

  • Committer: Bazaar Package Importer
  • Author(s): Adam Conrad, Benjamin Montgomery, Adam Conrad
  • Date: 2005-09-18 22:51:38 UTC
  • mfrom: (1.2.1 upstream) (2.1.1 sarge) (0.1.2 woody)
  • Revision ID: james.westby@ubuntu.com-20050918225138-seav22q6fyylb536
Tags: 5.4.7-3ubuntu1
[ Benjamin Montgomery ]
* Added a patch for amd64 and powerpc that disables the compiler
  option -fvisibility-inlines-hidden

[ Adam Conrad ]
* Added DPATCH_OPTION_CPP=1 to debian/patches/00options to make
  Benjamin's above changes work correctly with dpatch.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
<!-- page01.html,v 1.8 2000/03/19 20:09:23 jcej Exp -->
2
 
<HTML>
3
 
<HEAD>
4
 
   <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1">
5
 
   <META NAME="GENERATOR" CONTENT="Mozilla/4.04 [en] (X11; I; Linux 2.0.32 i486) [Netscape]">
6
 
   <META NAME="Author" CONTENT="James CE Johnson">
7
 
   <META NAME="Description" CONTENT="A first step towards using ACE productively">
8
 
   <TITLE>ACE Tutorial 006</TITLE>
9
 
</HEAD>
10
 
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
11
 
 
12
 
<CENTER><B><FONT SIZE=+2>ACE Tutorial 006</FONT></B></CENTER>
13
 
 
14
 
<CENTER><B><FONT SIZE=+2>Creating a thread-per-connection server</FONT></B></CENTER>
15
 
 
16
 
 
17
 
<P>
18
 
<HR WIDTH="100%">
19
 
 
20
 
<P>In this tutorial, we're going to extend Tutorial 5 to create a thread-per-connection
21
 
server.&nbsp; This implementation will create a new thread for each client
22
 
which connects to us.&nbsp; The ACE_Reactor is still used but only for
23
 
accepting new connections.&nbsp; The Client_Handler objects won't be registered
24
 
with the reactor.&nbsp; Instead, they'll be responsible for monitoring
25
 
their peer() directly.
26
 
<P>
27
 
Abstract:<sup>*</sup>
28
 
<ul>
29
 
Here, we build a thread-per-connection simple server. This is the next
30
 
step from a simple single-threaded server towards a multithreaded
31
 
server.
32
 
<p>
33
 
We make use of the Strategy Pattern in this example.
34
 
The ACE_Acceptor inherits form the ACE_Acceptor_Base class which
35
 
facilitates us to implement various different concurrency strategies
36
 
depending on whether the server is single-threaded or the server creates
37
 
a new thread per connection. This also allows us to extend the
38
 
capabilities of the server in the future by implementing a different
39
 
strategy.
40
 
<p>
41
 
This information is passed on to the Client_Handler
42
 
(remember ACE_Acceptor < Client_Handler, ACE_SOCK_ACCEPTOR > ?).
43
 
The Client_Handler is an ACE_Svc_Handler as the Svc_Handler is a
44
 
derivative of the Event_Handler and is associated with
45
 
ACE_Sock_Stream. It is also derived form the ACE_Task class which allows
46
 
us to have a thread per connection.
47
 
<p>
48
 
We incorporate the data processing in the svc() method, which will be
49
 
called per thread for the thread-per-connection server.
50
 
<p>
51
 
Note that here all the Client_Handler objects  aren't registered with the
52
 
reactor. The Reactor is only used to accept client connections. Once a
53
 
thread has been deicated per connection, the Client  Handler object
54
 
reponsible for that client connection now takes up the job of the
55
 
reactor and handles future events.
56
 
<p>
57
 
Thus a simple, thread-per-connection server has been built which doesnt
58
 
delve too deeply into mutli-threading issues.
59
 
</ul>
60
 
<font size=-1>* Abstract by Kirthika as always</font>
61
 
<P><HR WIDTH="100%">
62
 
<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page02.html">Continue This Tutorial</A>]</CENTER>
63