File: TestThread.h

package info (click to toggle)
gravitation 3%2Bdfsg1-1
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 2,124 kB
  • ctags: 1,535
  • sloc: cpp: 13,160; objc: 245; sh: 134; makefile: 130; perl: 67
file content (77 lines) | stat: -rw-r--r-- 1,361 bytes parent folder | download | duplicates (30)
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/*
 * Modification History
 *
 * 2000-December-13		Jason Rohrer
 * Created.
 *
 * 2001-January-27		Jason Rohrer
 * Switched to a ThreadSafePrinter in attempt to get it to work on Win32.
 * Changed print call to printf. 
 *
 * 2002-November-14		Jason Rohrer
 * Added missing destructor. 
 */

#include "minorGems/common.h"



#ifndef TEST_THREAD_CLASS_INCLUDED
#define TEST_THREAD_CLASS_INCLUDED

#include "Thread.h"

#include "ThreadSafePrinter.h"

#include <stdio.h>

/**
 * Test subclass of Thread class.  Useful for testing if platform-specific
 * thread implmentations are working.
 *
 * @author Jason Rohrer
 */
class TestThread : public Thread {
	
	public:
		/**
		 * Constructs a test thread and tells it how high to count to.
		 *
		 * @param inID id number thread will print along with count.
		 * @param inNumToCount thread will count from 0 to this number.
		 */
		TestThread( int inID, int inNumToCount );
		
		~TestThread();
		
		// override the run method from PThread
		void run();
	
	private:
		int mID;
		int mNumToCount;
	
	};



inline TestThread::TestThread( int inID, int inNumToCount ) 
	: mID( inID ), mNumToCount( inNumToCount ) {
	
	}



inline TestThread::~TestThread() {
	
	}



inline void TestThread::run() {
	for( int i=0; i<=mNumToCount; i++ ) {
		ThreadSafePrinter::printf( "Thread %d counting %d.\n", mID, i );
		}
	}	
	
#endif