Skip to content

Instantly share code, notes, and snippets.

@stevestreza
Created February 23, 2009 23:08
Show Gist options
  • Save stevestreza/69247 to your computer and use it in GitHub Desktop.
Save stevestreza/69247 to your computer and use it in GitHub Desktop.
25d24
> -(void)setSuspended:(BOOL)suspended;
23a24,25
>
> BOOL _suspended;
28a31
> - (void)setSuspended:(BOOL)suspended;
37a41
> _suspended = NO;
40,41c44
< _thread = [[NSThread alloc] initWithTarget: self selector: @selector( _workThread ) object: nil];
< [_thread start];
---
> [self _setupThread];
67c70,72
< [_trigger signal];
---
>
> if(!_suspended)
> [_trigger signal];
80,81c85,108
< - (void)stop
< {
---
> -(void)setSuspended:(BOOL)suspended{
> BOOL needsSignal = (_suspended && !suspended); // if it was suspended, and is not now
> BOOL needsSuspend = (!_suspended && suspended);
> _suspended = suspended;
>
> if(needsSignal){
> if([_thread isCancelled]){
> [self _setupThread];
> }
> [_trigger signal];
> }else if(needsSuspend){
> [self stop];
> }
> }
>
> -(void)_setupThread{
> [_thread release];
>
> _thread = [[NSThread alloc] initWithTarget: self selector: @selector( _workThread ) object: nil];
> [_thread start];
> }
>
> - (void)stop{
>
181a209,212
> -(void)setSuspended:(BOOL)suspended{
> [_impl setSuspended:suspended];
> }
>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment