Simplify new thread model, and make overriding thread behaviour possible:
* Reintroduce one status timer per request, so it can run with a different threading model (eg per-request thread) * Stop using a lock to block the request thread, and simply have a timer that runs forever doing nothing instead Most tests passing now... :)
Showing
2 changed files
with
11 additions
and
1 deletions
| @@ -392,6 +392,9 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | @@ -392,6 +392,9 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | ||
| 392 | 392 | ||
| 393 | // Will be ASIHTTPRequestRunLoopMode for synchronous requests, NSDefaultRunLoopMode for all other requests | 393 | // Will be ASIHTTPRequestRunLoopMode for synchronous requests, NSDefaultRunLoopMode for all other requests |
| 394 | NSString *runLoopMode; | 394 | NSString *runLoopMode; |
| 395 | + | ||
| 396 | + // This timer checks up on the request every 0.25 seconds, and updates progress | ||
| 397 | + NSTimer *statusTimer; | ||
| 395 | } | 398 | } |
| 396 | 399 | ||
| 397 | #pragma mark init / dealloc | 400 | #pragma mark init / dealloc |
| @@ -683,8 +686,15 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | @@ -683,8 +686,15 @@ extern unsigned long const ASIWWANBandwidthThrottleAmount; | ||
| 683 | // And also by ASIS3Request | 686 | // And also by ASIS3Request |
| 684 | + (NSString *)base64forData:(NSData *)theData; | 687 | + (NSString *)base64forData:(NSData *)theData; |
| 685 | 688 | ||
| 686 | -#pragma mark request threading behaviour | 689 | +#pragma mark threading behaviour |
| 687 | 690 | ||
| 691 | +// In the default implementation, all requests run in a single background thread | ||
| 692 | +// Advanced users only: Override this method in a subclass for a different threading behaviour | ||
| 693 | +// Eg: return [NSThread mainThread] to run all requests in the main thread | ||
| 694 | +// Alternatively, you can create a thread on demand, or manage a pool of threads | ||
| 695 | +// Threads returned by this method will need to run the runloop in default mode (eg CFRunLoopRun()) | ||
| 696 | +// Requests will stop the runloop when they complete | ||
| 697 | +// If you have multiple requests sharing the thread you'll need to restart the runloop when this happens | ||
| 688 | + (NSThread *)threadForRequest:(ASIHTTPRequest *)request; | 698 | + (NSThread *)threadForRequest:(ASIHTTPRequest *)request; |
| 689 | 699 | ||
| 690 | #pragma mark === | 700 | #pragma mark === |
This diff is collapsed. Click to expand it.
-
Please register or login to post a comment