vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
VVThreadLoop.h
1 
2 #if IPHONE
3 #import <UIKit/UIKit.h>
4 #else
5 #import <Cocoa/Cocoa.h>
6 #endif
7 #include <sys/time.h>
8 #import <unistd.h>
9 #include <libkern/OSAtomic.h>
10 
11 
12 
13 
15 
25 @interface VVThreadLoop : NSObject {
26  double interval;
27  double maxInterval;
28  BOOL running;
29  BOOL bail;
30  BOOL paused;
31  BOOL executingCallback;
32 
33  OSSpinLock valLock; // ONLY used for quickly accessing 'running', 'bail', 'paused', and 'executingCallback' in a threadsafe fashion
34 
35  id targetObj;
36  SEL targetSel;
37 }
38 
40 - (id) initWithTimeInterval:(double)i target:(id)t selector:(SEL)s;
42 - (id) initWithTimeInterval:(double)i;
43 - (void) generalInit;
45 - (void) start;
46 - (void) threadCallback;
47 - (void) threadProc;
49 - (void) pause;
50 - (void) resume;
52 - (void) stop;
54 - (void) stopAndWaitUntilDone;
56 - (double) interval;
58 - (void) setInterval:(double)i;
60 - (BOOL) running;
61 
62 @property (assign,readwrite) double maxInterval;
63 
64 @end
Simple class for spawning a thread which executes at a specified interval- simpler and easier to work...
Definition: VVThreadLoop.h:25
double interval()
The interval between executions, in seconds.
Definition: VVThreadLoop.m:218
id targetObj
NOT retained! If there's no valid target obj/sel pair, the instance sill simply call "threadProc" on ...
Definition: VVThreadLoop.h:35
BOOL running()
Whether or not the thread loop is running.
Definition: VVThreadLoop.m:224