ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/cebix/BasiliskII/src/MacOSX/NNThread.h
Revision: 1.1
Committed: 2002-03-16T04:00:25Z (22 years, 8 months ago) by nigel
Content type: text/plain
Branch: MAIN
CVS Tags: nigel-build-12, nigel-build-13, nigel-build-10, nigel-build-16, nigel-build-15
Log Message:
Initial revision of Mac OS X port code. Uses Objective-C++. Needs Mac OS 10.1

File Contents

# Content
1 //
2 // NNThread.h -Not Nextstep Thread?
3 // Nigel's Nice Thread?
4 //
5 // Revision 1.1, Wed Nov 7 2001.
6 //
7 // Created by Nigel Pearson on Tue Nov 28 2000.
8 // Public Domain. No rights reserved.
9 //
10
11 // Define what flavour of threading to use:
12 #define USE_NSTHREAD
13 //#define USE_PTHREAD
14
15 #import <Cocoa/Cocoa.h>
16
17 #import <mach/mach.h>
18 #import <mach/kern_return.h>
19
20 #ifdef USE_PTHREAD
21 #include <pthread.h>
22
23 struct pthreadArgs // This duplicates most of the stuff in the NNThread object
24 {
25 id *object;
26 SEL *sel;
27
28 NSAutoreleasePool *pool;
29 BOOL allocPool,
30 *completed;
31 };
32 #endif
33
34 @interface NNThread : NSObject
35 {
36 id object;
37 SEL sel;
38 thread_t machThread;
39 #ifdef USE_PTHREAD
40 pthread_t pThread;
41 struct pthreadArgs pthreadArgs;
42 #endif
43 NSAutoreleasePool *pool;
44 BOOL allocPool,
45 completed,
46 suspended;
47 }
48
49 - (NNThread *) initWithAutoReleasePool;
50 - (NNThread *) initSuspended: (BOOL) startSuspended
51 withAutoreleasePool: (BOOL) allocatePool;
52
53 - (void) perform: (SEL)action of: (id)receiver;
54 - (void) resume;
55 - (BOOL) start;
56 - (void) suspend;
57 - (void) terminate;
58
59 @end
60
61 typedef enum _NNTimeUnits
62 {
63 NNnanoSeconds = 1,
64 NNmicroSeconds = 2,
65 NNmilliSeconds = 3,
66 NNseconds = 4
67 }
68 NNTimeUnits;
69
70 #import <sys/time.h>
71
72 @interface NNTimer : NNThread
73 {
74 struct timespec delay;
75 BOOL repeating;
76 id timerObject;
77 SEL timerSel;
78 }
79
80 - (void) changeIntervalTo: (int)number units: (NNTimeUnits)units;
81 - (void) invalidate;
82
83 - (void) perform: (SEL)action of: (id)receiver
84 after: (int)number units: (NNTimeUnits)units;
85
86 - (void) repeat: (SEL)action of: (id)receiver
87 every: (int)number units: (NNTimeUnits)units;
88
89 @end