Coroutines/MYCoroutine.h
changeset 1 2475f871c218
parent 0 deb0ee0c5b21
     1.1 --- a/Coroutines/MYCoroutine.h	Tue Apr 29 17:05:32 2008 -0700
     1.2 +++ b/Coroutines/MYCoroutine.h	Wed Apr 30 14:18:49 2008 -0700
     1.3 @@ -15,7 +15,8 @@
     1.4  @interface MYCoroutine : NSObject
     1.5  {
     1.6      @private
     1.7 -    struct Coro *_coro;
     1.8 +    struct CoroX *_coro;
     1.9 +    NSInvocation *_invocation;
    1.10      NSString *_name;
    1.11  }
    1.12  
    1.13 @@ -33,42 +34,42 @@
    1.14  /** Creates but does not start a coroutine. */
    1.15  - (id) init;
    1.16  
    1.17 -/** Starts a new coroutine, and performs the given invocation on it.
    1.18 -    The current coroutine will block (i.e. this call won't return)
    1.19 -    until some other coroutine tells it to resume. */
    1.20 -- (void) startWithInvocation: (NSInvocation*)invocation;
    1.21  
    1.22 -/** Starts a new coroutine, invoking its -main method as its body.
    1.23 -    Since the default implementation of -main is empty, this only makes sense to call
    1.24 -    on an instance of a subclass of MYCoroutine that's overridden -main.
    1.25 -    The current coroutine will block (i.e. this call won't return)
    1.26 -    until some other coroutine tells it to resume. */
    1.27 -- (void) start;
    1.28 +@property (retain) NSInvocation *invocation;
    1.29 +
    1.30 +/** The stack size of the coroutine. You can only change this before calling -start! */
    1.31 +@property size_t stackSize;
    1.32 +
    1.33 +/** The coroutine's name. You can put anything you want here, as a debugging aid. */
    1.34 +@property (copy) NSString* name;
    1.35 +
    1.36  
    1.37  /** The "main" method that will be called if the coroutine is started with -start.
    1.38      The default implementation is empty, so a subclass using -start must override this. */
    1.39  - (void) main;
    1.40  
    1.41 -/** Returns control to an already-started (but blocked) coroutine.
    1.42 +
    1.43 +/** Returns control to a coroutine.
    1.44      The most recent -resume call made from within that coroutine will return.
    1.45      The current coroutine will block (i.e. this call won't return)
    1.46      until some other coroutine tells it to resume. */
    1.47  - (void) resume;
    1.48  
    1.49 +- (id) call;
    1.50  
    1.51 -/** The coroutine's name. You can put anything you want here, as a debugging aid. */
    1.52 -@property (copy) NSString* name;
    1.53 ++ (void) yieldToCaller: (id)value;
    1.54 +
    1.55  
    1.56  /** Returns YES if this is the currently executing coroutine. */
    1.57  @property (readonly) BOOL isCurrent;
    1.58  
    1.59 -/** The stack size of the coroutine. You can only change this before calling -start! */
    1.60 -@property size_t stackSize;
    1.61 -
    1.62  /** The number of bytes of stack space left on this coroutine. */
    1.63  @property (readonly) size_t bytesLeftOnStack;
    1.64  
    1.65  /** Returns YES if this coroutine is almost out of stack space (less than 8k left) */
    1.66  @property (readonly) BOOL stackSpaceAlmostGone;
    1.67  
    1.68 +
    1.69 ++ (void) setDefaultStackSize: (size_t)stackSize;
    1.70 +
    1.71  @end