diff options
Diffstat (limited to 'docs/tutorials/Chap_4/ex04.html')
-rw-r--r-- | docs/tutorials/Chap_4/ex04.html | 69 |
1 files changed, 0 insertions, 69 deletions
diff --git a/docs/tutorials/Chap_4/ex04.html b/docs/tutorials/Chap_4/ex04.html deleted file mode 100644 index 091433ba5be..00000000000 --- a/docs/tutorials/Chap_4/ex04.html +++ /dev/null @@ -1,69 +0,0 @@ -<HTML> -<HEAD> - <META HTTP-EQUIV="Content-Type" CONTENT="text/html; charset=iso-8859-1"> - <META NAME="Author" CONTENT="Ambreen Ilyas"> - <META NAME="GENERATOR" CONTENT="Mozilla/4.05 [en] (X11; I; SunOS 5.5.1 sun4u) [Netscape]"> - <TITLE>Example 4</TITLE> -</HEAD> -<BODY> -<FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> -<BR><FONT COLOR="#CC0000">//// This example is from the ACE Programmers -Guide.</FONT> -<BR><FONT COLOR="#CC0000">//// Chapter: "Thread Management"</FONT> -<BR><FONT COLOR="#CC0000">//// For details please see the guide at</FONT> -<BR><FONT COLOR="#CC0000">//// http://www.cs.wustl.edu/~schmidt/ACE.html</FONT> -<BR><FONT COLOR="#CC0000">//// AUTHOR: Umar Syyid (usyyid@hns.com)</FONT> -<BR><FONT COLOR="#CC0000">//// and Ambreen Ilyas (ambreen@bitsmart.com)</FONT> -<BR><FONT COLOR="#CC0000">/////////////////////////////////////////////////////////////////////////////////////////////////////////////</FONT> - -<P><FONT COLOR="#CC0000">//Example 4</FONT> -<BR><FONT COLOR="#000099">#include</FONT> <FONT COLOR="#006600">"ace/OS.h"</FONT> -<BR><FONT COLOR="#000099">#include</FONT><FONT COLOR="#006600"> "ace/Token.h"</FONT> - -<P><FONT COLOR="#FF0000">//Arguments that are to be passed to the worker -thread are passed</FONT> -<BR><FONT COLOR="#FF0000">//through this class.</FONT> -<BR>class Args{ -<BR>public: -<BR>Args(int iterations): -<BR> mutex_(),iterations_(iterations){} -<BR>ACE_Token mutex_; -<BR>int iterations_; -<BR>}; - -<P><FONT COLOR="#FF0000">//The starting point for the worker threads</FONT> -<BR>static void* -<BR>worker(void*arguments){ -<BR>Args *arg= (Args*) arguments; -<BR>for(int i=0;i<arg->iterations_;i++){ -<BR> ACE_DEBUG((LM_DEBUG,"(%t) Trying to get a hold of this iteration\n")); -<BR><FONT COLOR="#FF0000"> //This is our critical section</FONT> -<BR> arg->mutex_.acquire(); -<BR> ACE_DEBUG((LM_DEBUG,"(%t) This is iteration number %d\n",i)); -<BR><FONT COLOR="#FF0000"> //work</FONT> -<BR> ACE_OS::sleep(2); -<BR> arg->mutex_.release(); -<BR> } -<BR>return 0; -<BR>} -<BR> - -<P>int main(int argc, char*argv[]){ -<BR>if(argc<4){ -<BR> ACE_OS::printf("Usage: egx <number_of_threads> -<BR> <number_of_iterations> <lock_type>\n"); -<BR> ACE_OS::exit(1); -<BR> } - -<P><FONT COLOR="#FF0000">//Setup the arguments</FONT> -<BR>Args arg(ACE_OS::atoi(argv[2])); -<BR><FONT COLOR="#FF0000">//Spawn the worker threads</FONT> -<BR>ACE_Thread::spawn_n(ACE_OS::atoi(argv[1]),(ACE_THR_FUNC)worker,(void*)&arg); - -<P>while(ACE_Thread::join(NULL,NULL,NULL)==0); - -<P>} - -<P> <A HREF="ex05.html">Next Example</A> -</BODY> -</HTML> |