Differences From Artifact [b78dbdb727]:
- File src/OFRunLoop.m — part of check-in [a4494ec477] at 2012-09-11 16:48:49 on branch trunk — Add OFTimer and OFRunLoop. (user: js, size: 3047) [annotate] [blame] [check-ins using]
To Artifact [30c14bee93]:
- File
src/OFRunLoop.m
— part of check-in
[55e7d380e4]
at
2012-09-12 06:11:06
on branch trunk
— OFRunLoop: Remove timer before possible read.
A timer always needs to be removed before its fireDate is changed,
otherwise, this will break the ordering in the OFSortedList. (user: js, size: 3141) [annotate] [blame] [check-ins using]
︙ | ︙ | |||
85 86 87 88 89 90 91 | - (void)run { for (;;) { void *pool = objc_autoreleasePoolPush(); OFDate *now = [OFDate date]; @synchronized (timersQueue) { | | | > > | | > | | > | 85 86 87 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 | - (void)run { for (;;) { void *pool = objc_autoreleasePoolPush(); OFDate *now = [OFDate date]; @synchronized (timersQueue) { of_list_object_t *iter; while ((iter = [timersQueue firstListObject]) != NULL) { void *pool2 = objc_autoreleasePoolPush(); OFTimer *timer; /* * If a timer is in the future, we can * stop now as it is sorted. */ if ([[iter->object fireDate] compare: now] == OF_ORDERED_DESCENDING) break; timer = [[iter->object retain] autorelease]; [timersQueue removeListObject: iter]; [timer fire]; objc_autoreleasePoolPop(pool2); } /* Sleep until we reach the next timer */ if (iter != NULL) [OFThread sleepUntilDate: [iter->object fireDate]]; else { |
︙ | ︙ |