Differences From Artifact [af64aebbb7]:
- File
src/OFRunLoop.m
— part of check-in
[df53f06922]
at
2012-09-12 06:11:46
on branch trunk
— Run loops have a stream observer now.
This makes async I/O possible! (user: js, size: 2880) [annotate] [blame] [check-ins using]
To Artifact [e04d2c2152]:
- File src/OFRunLoop.m — part of check-in [34e548c51d] at 2012-09-12 06:41:48 on branch trunk — OFRunLoop: Reduce the time the lock is held. (user: js, size: 2855) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
88 89 90 91 92 93 94 95 96 | } - (void)run { for (;;) { void *pool = objc_autoreleasePoolPush(); OFDate *now = [OFDate date]; @synchronized (timersQueue) { | > > > > > > > > > > > > > > > > > > > < | < < < | < < < < < < < < < | | | < | | < < < < | | | | | | | | | < | 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 | } - (void)run { for (;;) { void *pool = objc_autoreleasePoolPush(); OFDate *now = [OFDate date]; OFTimer *timer; OFDate *nextTimer; @synchronized (timersQueue) { of_list_object_t *listObject = [timersQueue firstListObject]; if (listObject != NULL && [[listObject->object fireDate] compare: now] != OF_ORDERED_DESCENDING) { timer = [[listObject->object retain] autorelease]; [timersQueue removeListObject: listObject]; } else timer = nil; } [timer fire]; @synchronized (timersQueue) { nextTimer = [[timersQueue firstObject] fireDate]; } /* Watch for stream events until the next timer is due */ if (nextTimer != nil) { double timeout = [nextTimer timeIntervalSinceNow]; if (timeout > 0) [streamObserver observeWithTimeout: timeout]; } else { /* * No more timers: Just watch for streams until we get * an event. If a timer is added by another thread, it * cancels the observe. */ [streamObserver observe]; } objc_autoreleasePoolPop(pool); } } @end |