blob: 84dc9c9c281627f53092a0522589c9d8b0fc5f9d (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
<!-- $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 018</TITLE>
</HEAD>
<BODY TEXT="#000000" BGCOLOR="#FFFFFF" LINK="#000FFF" VLINK="#FF0F0F">
<CENTER><B><FONT SIZE=+2>ACE Tutorial 018</FONT></B></CENTER>
<CENTER><B><FONT SIZE=+2>The FIFO Nature of ACE_Token</FONT></B></CENTER>
<P>
<HR WIDTH="100%">
Our main() just keeps getting simpler! I guess that's a good thing.
<P>
What we've done is create two Task-derived objects that test different
locking mechanisms. The Token object uses ACE_Token and the Mutex
object uses ACE_Mutex. When you execute the application you should
see quite a difference in thread utilization. At the end of the
tutorial I've included a link to the output of a typical run of the
application.
<HR>
<PRE>
<font color=red>// $Id$</font>
<font color=red>// Get our two Test derivatives...</font>
<font color=blue>#include</font> "<font color=green>Token_i.h</font>"
<font color=blue>#include</font> "<font color=green>Mutex_i.h</font>"
int main(int,char**)
{
<font color=red>// See what an ACE_Token does for us.</font>
Token token;
token.run();
<font color=red>// And now the ACE_Mutex.</font>
Mutex mutex;
mutex.run();
return(0);
}
<font color=blue>#if defined</font> (<font color=purple>ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION</font>)
template class Test_T <ACE_Mutex>;
template class Test_T <ACE_Token>;
template class ACE_Atomic_Op <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> Test_T <ACE_Mutex>
<font color=blue>#pragma</font> <font color=purple>instantiate</font> Test_T <ACE_Token>
<font color=blue>#pragma</font> <font color=purple>instantiate</font> ACE_Atomic_Op <ACE_Mutex, int>
<font color=blue>#endif</font> <font color=red>/* ACE_HAS_EXPLICIT_TEMPLATE_INSTANTIATION */</font>
</PRE>
<P><HR WIDTH="100%">
<CENTER>[<A HREF="../online-tutorials.html">Tutorial Index</A>] [<A HREF="page03.html">Continue This Tutorial</A>]</CENTER>
|