Overview
Comment: | OFRunLoop: Reduce the time the lock is held. |
---|---|
Downloads: | Tarball | ZIP archive | SQL archive |
Timelines: | family | ancestors | descendants | both | trunk |
Files: | files | file ages | folders |
SHA3-256: |
34e548c51d94855c2a64082c0d1288df |
User & Date: | js on 2012-09-12 06:41:48 |
Other Links: | manifest | tags |
Context
2012-09-12
| ||
08:03 | OFTimer: Add support for invoking blocks. check-in: dde45db1ef user: js tags: trunk | |
06:41 | OFRunLoop: Reduce the time the lock is held. check-in: 34e548c51d user: js tags: trunk | |
06:11 | Run loops have a stream observer now. check-in: df53f06922 user: js tags: trunk | |
Changes
Modified src/OFRunLoop.m from [af64aebbb7] to [e04d2c2152].
︙ | ︙ | |||
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 |