GeezerVisonThe World Wide Web, restored to 800 pixels of glory. |
| Home|About|Gaming cabinet|Archives|How it works|Starter sites |
GeezerVison is showing github.com — STNetTaskQueue/STNetTaskQueue/STNetTaskChain.m at master · kevin-lyn/STNetTaskQueue Expand file tree/ Copy pathSTNetTaskChain.mMore file actions 102 lines (86 loc) · 1.92 KB / Copy pathSTNetTaskChain.mFile metadata and controls102 lines (86 loc) · 1.92 KB 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 // // STNetTaskChain.m // STNetTaskQueue // // Created by Kevin Lin on 29/11/14. // Copyright (c) 2014 Sth4Me. All rights reserved. // #import "STNetTaskChain.h" #import "STNetTask.h" #import "STNetTaskQueue.h" @interface STNetTaskChain()<STNetTaskDelegate> @property (nonatomic, strong) NSArray *allTasks; @property (nonatomic, assign) int taskIndex; @end @implementation STNetTaskChain - (void)setTasks:(STNetTask *)task, ... { NSMutableArray *tasks = [NSMutableArray array]; va_list args; va_start(args, task); STNetTask *nextTask = nil; for (nextTask = task; nextTask != nil; nextTask = va_arg(args, STNetTask *)) { [tasks addObject:nextTask]; [self.queue addTaskDelegate:self uri:nextTask.uri]; } va_end(args); self.allTasks = tasks; } - (BOOL)onNextRequest:(STNetTask *)task { return YES; } - (void)onNextResponse:(STNetTask *)task { } - (void)start { if (_started) { return; } _started = YES; _error = nil; self.taskIndex = 0; [self nextRequest]; } - (void)cancel { if (!_started) { return; } _started = NO; for (STNetTask *task in self.allTasks) { [self.queue cancelTask:task]; } } - (void)nextRequest { while (_started) { if (self.taskIndex >= self.allTasks.count) { _started = NO; [self.delegate netTaskChainDidEnd:self]; return; } STNetTask *task = [self.allTasks objectAtIndex:self.taskIndex]; self.taskIndex++; if ([self onNextRequest:task]) { [self.queue addTask:task]; return; } } } - (void)netTaskDidEnd:(STNetTask *)task { if (![self.allTasks containsObject:task]) { return; } if (task.error) { _error = task.error; [self.delegate netTaskChainDidEnd:self]; } else { [self onNextResponse:task]; [self nextRequest]; } } @end |
| You are visitor 01402775 — GeezerVison does not store the pages you look up. Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required. |