Overview
Context
Changes
Modified src/OFCondition.h
from [645e8c4436]
to [a30632d8ca].
︙ | | |
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
|
-
+
|
/*!
* @brief Blocks the current thread until another thread calls @ref signal,
* @ref broadcast or the timeout is reached.
*
* @param timeInterval The time interval until the timeout is reached
* @return Whether the condition has been signaled
*/
- (bool)waitForTimeInterval: (double)timeInterval;
- (bool)waitForTimeInterval: (of_time_interval_t)timeInterval;
/*!
* @brief Blocks the current thread until another thread calls @ref signal,
* @ref broadcast or the timeout is reached.
*
* @param date The date at which the timeout is reached
* @return Whether the condition has been signaled
|
︙ | | |
Modified src/OFCondition.m
from [d442f66f9a]
to [570c67aefb].
︙ | | |
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
-
+
|
- (void)wait
{
if (!of_condition_wait(&_condition, &_mutex))
@throw [OFConditionWaitFailedException
exceptionWithCondition: self];
}
- (bool)waitForTimeInterval: (double)timeInterval
- (bool)waitForTimeInterval: (of_time_interval_t)timeInterval
{
return of_condition_timed_wait(&_condition, &_mutex, timeInterval);
}
- (bool)waitUntilDate: (OFDate*)date
{
return of_condition_timed_wait(&_condition, &_mutex,
|
︙ | | |
Modified src/OFDate.h
from [fcda070626]
to [496c98e81f].
︙ | | |
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
|
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
|
-
+
-
+
-
+
|
@class OFConstantString;
/*!
* @brief A class for storing, accessing and comparing dates.
*/
@interface OFDate: OFObject <OFCopying, OFComparing, OFSerialization>
{
double _seconds;
of_time_interval_t _seconds;
}
/*!
* @brief Creates a new OFDate with the current date and time.
*
* @return A new, autoreleased OFDate with the current date and time
*/
+ (instancetype)date;
/*!
* @brief Creates a new OFDate with the specified date and time since
* 1970-01-01T00:00:00Z.
*
* @param seconds The seconds since 1970-01-01T00:00:00Z
* @return A new, autoreleased OFDate with the specified date and time
*/
+ (instancetype)dateWithTimeIntervalSince1970: (double)seconds;
+ (instancetype)dateWithTimeIntervalSince1970: (of_time_interval_t)seconds;
/*!
* @brief Creates a new OFDate with the specified date and time since now.
*
* @param seconds The seconds since now
* @return A new, autoreleased OFDate with the specified date and time
*/
+ (instancetype)dateWithTimeIntervalSinceNow: (double)seconds;
+ (instancetype)dateWithTimeIntervalSinceNow: (of_time_interval_t)seconds;
/*!
* @brief Creates a new OFDate with the specified string in the specified
* format.
*
* The time zone used is UTC. See @ref dateWithLocalDateString:format: if you
* want local time.
|
︙ | | |
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
|
-
+
-
+
|
/*!
* @brief Initializes an already allocated OFDate with the specified date and
* time since 1970-01-01T00:00:00Z.
*
* @param seconds The seconds since 1970-01-01T00:00:00Z
* @return An initialized OFDate with the specified date and time
*/
- initWithTimeIntervalSince1970: (double)seconds;
- initWithTimeIntervalSince1970: (of_time_interval_t)seconds;
/*!
* @brief Initializes an already allocated OFDate with the specified date and
* time since now.
*
* @param seconds The seconds since now
* @return An initialized OFDate with the specified date and time
*/
- initWithTimeIntervalSinceNow: (double)seconds;
- initWithTimeIntervalSinceNow: (of_time_interval_t)seconds;
/*!
* @brief Initializes an already allocated OFDate with the specified string in
* the specified format.
*
* The time zone used is UTC. If a time zone is specified anyway, an
* OFInvalidFormatException is thrown. See @ref initWithLocalDateString:format:
|
︙ | | |
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
|
-
+
-
+
-
+
-
+
|
- (OFDate*)laterDate: (OFDate*)otherDate;
/*!
* @brief Returns the seconds since 1970-01-01T00:00:00Z.
*
* @return The seconds since 1970-01-01T00:00:00Z
*/
- (double)timeIntervalSince1970;
- (of_time_interval_t)timeIntervalSince1970;
/*!
* @brief Returns the seconds the receiver is after the date.
*
* @param otherDate Date date to generate the difference with receiver
* @return The seconds the receiver is after the date.
*/
- (double)timeIntervalSinceDate: (OFDate*)otherDate;
- (of_time_interval_t)timeIntervalSinceDate: (OFDate*)otherDate;
/*!
* @brief Returns the seconds the receiver is in the future.
*
* @return The seconds the receiver is in the future
*/
- (double)timeIntervalSinceNow;
- (of_time_interval_t)timeIntervalSinceNow;
/*!
* @brief Creates a new date with the specified time interval added.
*
* @param seconds The seconds after the date
* @return A new, autoreleased OFDate
*/
- (OFDate*)dateByAddingTimeInterval: (double)seconds;
- (OFDate*)dateByAddingTimeInterval: (of_time_interval_t)seconds;
@end
|
Modified src/OFDate.m
from [f357555e03]
to [8e1ed139e9].
︙ | | |
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
|
-
+
-
+
|
#endif
+ (instancetype)date
{
return [[[self alloc] init] autorelease];
}
+ (instancetype)dateWithTimeIntervalSince1970: (double)seconds
+ (instancetype)dateWithTimeIntervalSince1970: (of_time_interval_t)seconds
{
return [[[self alloc]
initWithTimeIntervalSince1970: seconds] autorelease];
}
+ (instancetype)dateWithTimeIntervalSinceNow: (double)seconds
+ (instancetype)dateWithTimeIntervalSinceNow: (of_time_interval_t)seconds
{
return [[[self alloc]
initWithTimeIntervalSinceNow: seconds] autorelease];
}
+ (instancetype)dateWithDateString: (OFString*)string
format: (OFString*)format
|
︙ | | |
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
-
+
-
+
-
+
|
struct timeval t;
self = [super init];
OF_ENSURE(gettimeofday(&t, NULL) == 0);
_seconds = t.tv_sec;
_seconds += (double)t.tv_usec / 1000000;
_seconds += (of_time_interval_t)t.tv_usec / 1000000;
return self;
}
- initWithTimeIntervalSince1970: (double)seconds
- initWithTimeIntervalSince1970: (of_time_interval_t)seconds
{
self = [super init];
_seconds = seconds;
return self;
}
- initWithTimeIntervalSinceNow: (double)seconds
- initWithTimeIntervalSinceNow: (of_time_interval_t)seconds
{
self = [self init];
_seconds += seconds;
return self;
}
|
︙ | | |
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
|
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
|
-
+
-
+
-
+
-
+
-
+
-
+
|
if ([self compare: otherDate] == OF_ORDERED_ASCENDING)
return [[otherDate retain] autorelease];
return [[self retain] autorelease];
}
- (double)timeIntervalSince1970
- (of_time_interval_t)timeIntervalSince1970
{
return _seconds;
}
- (double)timeIntervalSinceDate: (OFDate*)otherDate
- (of_time_interval_t)timeIntervalSinceDate: (OFDate*)otherDate
{
return _seconds - otherDate->_seconds;
}
- (double)timeIntervalSinceNow
- (of_time_interval_t)timeIntervalSinceNow
{
struct timeval t;
double seconds;
of_time_interval_t seconds;
OF_ENSURE(!gettimeofday(&t, NULL));
seconds = t.tv_sec;
seconds += (double)t.tv_usec / 1000000;
seconds += (of_time_interval_t)t.tv_usec / 1000000;
return _seconds - seconds;
}
- (OFDate*)dateByAddingTimeInterval: (double)seconds
- (OFDate*)dateByAddingTimeInterval: (of_time_interval_t)seconds
{
return [OFDate dateWithTimeIntervalSince1970: _seconds + seconds];
}
@end
|
Modified src/OFObject.h
from [b36db29afe]
to [1fca43414f].
︙ | | |
186
187
188
189
190
191
192
193
194
195
196
197
198
199
|
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
+
+
+
+
+
|
typedef struct of_range_t {
/*! The start of the range */
size_t location;
/*! The length of the range */
size_t length;
} of_range_t;
/*!
* @brief A time interval in seconds.
*/
typedef double of_time_interval_t;
/*!
* @brief A point.
*/
typedef struct of_point_t {
/*! The x coordinate of the point */
float x;
/*! The y coordinate of the point */
|
︙ | | |
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
|
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
|
-
+
-
+
-
+
|
/*!
* @brief Performs the specified selector after the specified delay.
*
* @param selector The selector to perform
* @param delay The delay after which the selector will be performed
*/
- (void)performSelector: (SEL)selector
afterDelay: (double)delay;
afterDelay: (of_time_interval_t)delay;
/*!
* @brief Performs the specified selector with the specified object after the
* specified delay.
*
* @param selector The selector to perform
* @param object The object that is passed to the method specified by the
* selector
* @param delay The delay after which the selector will be performed
*/
- (void)performSelector: (SEL)selector
withObject: (id)object
afterDelay: (double)delay;
afterDelay: (of_time_interval_t)delay;
/*!
* @brief Performs the specified selector with the specified objects after the
* specified delay.
*
* @param selector The selector to perform
* @param object1 The first object that is passed to the method specified by the
* selector
* @param object2 The second object that is passed to the method specified by
* the selector
* @param delay The delay after which the selector will be performed
*/
- (void)performSelector: (SEL)selector
withObject: (id)object1
withObject: (id)object2
afterDelay: (double)delay;
afterDelay: (of_time_interval_t)delay;
#ifdef OF_HAVE_THREADS
/*!
* @brief Performs the specified selector on the specified thread.
*
* @param selector The selector to perform
* @param thread The thread on which to perform the selector
|
︙ | | |
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
|
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
|
-
+
-
+
-
+
|
*
* @param selector The selector to perform
* @param thread The thread on which to perform the selector
* @param delay The delay after which the selector will be performed
*/
- (void)performSelector: (SEL)selector
onThread: (OFThread*)thread
afterDelay: (double)delay;
afterDelay: (of_time_interval_t)delay;
/*!
* @brief Performs the specified selector on the specified thread with the
* specified object after the specified delay.
*
* @param selector The selector to perform
* @param thread The thread on which to perform the selector
* @param object The object that is passed to the method specified by the
* selector
* @param delay The delay after which the selector will be performed
*/
- (void)performSelector: (SEL)selector
onThread: (OFThread*)thread
withObject: (id)object
afterDelay: (double)delay;
afterDelay: (of_time_interval_t)delay;
/*!
* @brief Performs the specified selector on the specified thread with the
* specified objects after the specified delay.
*
* @param selector The selector to perform
* @param thread The thread on which to perform the selector
* @param object1 The first object that is passed to the method specified by the
* selector
* @param object2 The second object that is passed to the method specified by
* the selector
* @param delay The delay after which the selector will be performed
*/
- (void)performSelector: (SEL)selector
onThread: (OFThread*)thread
withObject: (id)object1
withObject: (id)object2
afterDelay: (double)delay;
afterDelay: (of_time_interval_t)delay;
#endif
/*!
* @brief This method is called when @ref resolveClassMethod: or
* @ref resolveInstanceMethod: returned false. It should return a target
* to which the message should be forwarded.
*
|
︙ | | |
Modified src/OFObject.m
from [3b4e65cff2]
to [12e6e740e4].
︙ | | |
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
|
-
+
-
+
-
+
|
return imp(self, selector, object1, object2);
#elif defined(OF_APPLE_RUNTIME)
return objc_msgSend(self, selector, object1, object2);
#endif
}
- (void)performSelector: (SEL)selector
afterDelay: (double)delay
afterDelay: (of_time_interval_t)delay
{
void *pool = objc_autoreleasePoolPush();
[OFTimer scheduledTimerWithTimeInterval: delay
target: self
selector: selector
repeats: false];
objc_autoreleasePoolPop(pool);
}
- (void)performSelector: (SEL)selector
withObject: (id)object
afterDelay: (double)delay
afterDelay: (of_time_interval_t)delay
{
void *pool = objc_autoreleasePoolPush();
[OFTimer scheduledTimerWithTimeInterval: delay
target: self
selector: selector
object: object
repeats: false];
objc_autoreleasePoolPop(pool);
}
- (void)performSelector: (SEL)selector
withObject: (id)object1
withObject: (id)object2
afterDelay: (double)delay
afterDelay: (of_time_interval_t)delay
{
void *pool = objc_autoreleasePoolPush();
[OFTimer scheduledTimerWithTimeInterval: delay
target: self
selector: selector
object: object1
|
︙ | | |
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
|
-
+
-
+
-
+
|
[timer waitUntilDone];
objc_autoreleasePoolPop(pool);
}
- (void)performSelector: (SEL)selector
onThread: (OFThread*)thread
afterDelay: (double)delay
afterDelay: (of_time_interval_t)delay
{
void *pool = objc_autoreleasePoolPush();
[[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay
target: self
selector: selector
repeats: false]];
objc_autoreleasePoolPop(pool);
}
- (void)performSelector: (SEL)selector
onThread: (OFThread*)thread
withObject: (id)object
afterDelay: (double)delay
afterDelay: (of_time_interval_t)delay
{
void *pool = objc_autoreleasePoolPush();
[[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay
target: self
selector: selector
object: object
repeats: false]];
objc_autoreleasePoolPop(pool);
}
- (void)performSelector: (SEL)selector
onThread: (OFThread*)thread
withObject: (id)object1
withObject: (id)object2
afterDelay: (double)delay
afterDelay: (of_time_interval_t)delay
{
void *pool = objc_autoreleasePoolPush();
[[thread runLoop] addTimer: [OFTimer timerWithTimeInterval: delay
target: self
selector: selector
object: object1
|
︙ | | |
Modified src/OFRunLoop.m
from [5f0333dffc]
to [e29f8ae799].
︙ | | |
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
|
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
|
+
-
+
|
} @finally {
[_timersQueueLock unlock];
}
#endif
/* Watch for stream events until the next timer is due */
if (nextTimer != nil) {
of_time_interval_t timeout =
double timeout = [nextTimer timeIntervalSinceNow];
[nextTimer timeIntervalSinceNow];
if (timeout > 0) {
#if defined(OF_HAVE_SOCKETS)
[_streamObserver
observeForTimeInterval: timeout];
#elif defined(OF_HAVE_THREADS)
[_condition lock];
|
︙ | | |
Modified src/OFStreamObserver.h
from [1c16f3d3a2]
to [de0e796056].
︙ | | |
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
|
-
+
|
/*!
* @brief Observes all streams until an event happens on a stream or the
* timeout is reached.
*
* @param timeInterval The time to wait for an event, in seconds
* @return A boolean whether events occurred during the timeinterval
*/
- (bool)observeForTimeInterval: (double)timeInterval;
- (bool)observeForTimeInterval: (of_time_interval_t)timeInterval;
/*!
* @brief Observes all streams until an event happens on a stream or the
* timeout is reached.
*
* @param date The until which to observe
* @return A boolean whether events occurred until the specified date
|
︙ | | |
Modified src/OFStreamObserver.m
from [f4afa0c360]
to [8b0d12d65c].
︙ | | |
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
|
-
+
|
}
- (void)observe
{
[self observeForTimeInterval: -1];
}
- (bool)observeForTimeInterval: (double)timeInterval
- (bool)observeForTimeInterval: (of_time_interval_t)timeInterval
{
OF_UNRECOGNIZED_SELECTOR
}
- (bool)observeUntilDate: (OFDate*)date
{
return [self observeForTimeInterval: [date timeIntervalSinceNow]];
|
︙ | | |
Modified src/OFStreamObserver_kqueue.m
from [2b799f2ea6]
to [5ec1bb5587].
︙ | | |
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
|
-
+
|
{
struct kevent event;
EV_SET(&event, fd, EVFILT_WRITE, EV_DELETE, 0, 0, 0);
[_changeList addItem: &event];
}
- (bool)observeForTimeInterval: (double)timeInterval
- (bool)observeForTimeInterval: (of_time_interval_t)timeInterval
{
void *pool = objc_autoreleasePoolPush();
struct timespec timeout;
struct kevent eventList[EVENTLIST_SIZE];
int i, events, realEvents = 0;
timeout.tv_sec = (time_t)timeInterval;
|
︙ | | |
Modified src/OFStreamObserver_poll.m
from [01d8b3fa23]
to [c4a5405d62].
︙ | | |
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
|
-
+
|
- (void)OF_removeFileDescriptorForWriting: (int)fd
{
[self OF_removeFileDescriptor: fd
withEvents: POLLOUT];
}
- (bool)observeForTimeInterval: (double)timeInterval
- (bool)observeForTimeInterval: (of_time_interval_t)timeInterval
{
void *pool = objc_autoreleasePoolPush();
struct pollfd *FDs;
size_t i, nFDs, realEvents = 0;
[self OF_processQueue];
|
︙ | | |
Modified src/OFStreamObserver_select.m
from [5191921275]
to [deba7055bd].
︙ | | |
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
|
-
+
|
{
FD_CLR(fd, &_writeFDs);
if (!FD_ISSET(fd, &_readFDs))
FD_CLR(fd, &_exceptFDs);
}
- (bool)observeForTimeInterval: (double)timeInterval
- (bool)observeForTimeInterval: (of_time_interval_t)timeInterval
{
void *pool = objc_autoreleasePoolPush();
OFStream **objects;
fd_set readFDs;
fd_set writeFDs;
fd_set exceptFDs;
struct timeval timeout;
|
︙ | | |
Modified src/OFThread.h
from [384c6bb853]
to [42d02c0030].
︙ | | |
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
|
-
+
-
+
|
+ (OFMutableDictionary*)threadDictionary;
#endif
/*!
* @brief Suspends execution of the current thread for the specified time
* interval.
*
* @param seconds The number of seconds to sleep
* @param timeInterval The number of seconds to sleep
*/
+ (void)sleepForTimeInterval: (double)seconds;
+ (void)sleepForTimeInterval: (of_time_interval_t)timeInterval;
/*!
* @brief Suspends execution of the current thread until the specified date.
*
* @param date The date to wait for
*/
+ (void)sleepUntilDate: (OFDate*)date;
|
︙ | | |
Modified src/OFThread.m
from [4151197f7a]
to [bbc593cb97].
︙ | | |
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
|
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
|
-
+
-
+
-
+
-
+
-
-
+
+
-
+
-
+
-
-
+
+
+
|
if (thread->_threadDictionary == nil)
thread->_threadDictionary = [[OFMutableDictionary alloc] init];
return thread->_threadDictionary;
}
#endif
+ (void)sleepForTimeInterval: (double)seconds
+ (void)sleepForTimeInterval: (of_time_interval_t)timeInterval
{
if (seconds < 0)
if (timeInterval < 0)
@throw [OFOutOfRangeException exception];
#if defined(_WIN32)
if (seconds * 1000 > UINT_MAX)
if (timeInterval * 1000 > UINT_MAX)
@throw [OFOutOfRangeException exception];
Sleep((unsigned int)(seconds * 1000));
Sleep((unsigned int)(timeInterval * 1000));
#elif defined(HAVE_NANOSLEEP)
struct timespec rqtp;
rqtp.tv_sec = (time_t)seconds;
rqtp.tv_nsec = lrint((seconds - rqtp.tv_sec) * 1000000000);
rqtp.tv_sec = (time_t)timeInterval;
rqtp.tv_nsec = lrint((timeInterval - rqtp.tv_sec) * 1000000000);
if (rqtp.tv_sec != floor(seconds))
if (rqtp.tv_sec != floor(timeInterval))
@throw [OFOutOfRangeException exception];
nanosleep(&rqtp, NULL);
#else
if (seconds > UINT_MAX)
if (timeInterval > UINT_MAX)
@throw [OFOutOfRangeException exception];
sleep((unsigned int)seconds);
usleep((useconds_t)lrint((seconds - floor(seconds)) * 1000000));
sleep((unsigned int)timeInterval);
usleep((useconds_t)lrint(
(timeInterval - floor(timeInterval)) * 1000000));
#endif
}
+ (void)sleepUntilDate: (OFDate*)date
{
[self sleepForTimeInterval: [date timeIntervalSinceNow]];
}
|
︙ | | |
Modified src/OFTimer.h
from [48ec421595]
to [d695d51e39].
︙ | | |
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
|
-
+
|
/*!
* @brief A class for creating and firing timers.
*/
@interface OFTimer: OFObject <OFComparing>
{
OFDate *_fireDate;
double _interval;
of_time_interval_t _interval;
id _target, _object1, _object2;
SEL _selector;
uint8_t _arguments;
bool _repeats;
#ifdef OF_HAVE_BLOCKS
of_timer_block_t _block;
#endif
|
︙ | | |
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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
|
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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
|
-
+
-
-
+
-
+
-
-
+
-
+
-
-
+
-
+
-
-
+
-
+
-
-
+
-
+
-
-
+
-
+
-
-
+
-
+
-
-
+
-
+
-
+
|
#ifdef OF_HAVE_PROPERTIES
@property (retain) OFDate *fireDate;
#endif
/*!
* @brief Creates and schedules a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param repeats Whether the timer repeats after it has been executed
* @return A new, autoreleased timer
*/
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
repeats: (bool)repeats;
/*!
* @brief Creates and schedules a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param object An object to pass when calling the selector on the target
* @param repeats Whether the timer repeats after it has been executed
* @return A new, autoreleased timer
*/
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object
repeats: (bool)repeats;
/*!
* @brief Creates and schedules a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param object1 The first object to pass when calling the selector on the
* target
* @param object2 The second object to pass when calling the selector on the
* target
* @param repeats Whether the timer repeats after it has been executed
* @return A new, autoreleased timer
*/
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object1
object: (id)object2
repeats: (bool)repeats;
#ifdef OF_HAVE_BLOCKS
/*!
* @brief Creates and schedules a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param repeats Whether the timer repeats after it has been executed
* @param block The block to invoke when the timer fires
* @return A new, autoreleased timer
*/
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
repeats: (bool)repeats
block: (of_timer_block_t)block;
#endif
/*!
* @brief Creates a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param repeats Whether the timer repeats after it has been executed
* @return A new, autoreleased timer
*/
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
repeats: (bool)repeats;
/*!
* @brief Creates a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param object An object to pass when calling the selector on the target
* @param repeats Whether the timer repeats after it has been executed
* @return A new, autoreleased timer
*/
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object
repeats: (bool)repeats;
/*!
* @brief Creates a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param object1 The first object to pass when calling the selector on the
* target
* @param object2 The second object to pass when calling the selector on the
* target
* @param repeats Whether the timer repeats after it has been executed
* @return A new, autoreleased timer
*/
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object1
object: (id)object2
repeats: (bool)repeats;
#ifdef OF_HAVE_BLOCKS
/*!
* @brief Creates a new timer with the specified time interval.
*
* @param interval The time interval after which the timer should be executed
* @param timeInterval The time interval after which the timer should be fired
* when fired
* @param repeats Whether the timer repeats after it has been executed
* @param block The block to invoke when the timer fires
* @return A new, autoreleased timer
*/
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
repeats: (bool)repeats
block: (of_timer_block_t)block;
#endif
/*!
* @brief Initializes an already allocated timer with the specified time
* interval.
*
* @param fireDate The date at which the timer should fire
* @param interval The time interval after which to repeat the timer, if it is
* a repeating timer
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param repeats Whether the timer repeats after it has been executed
* @return An initialized timer
*/
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
target: (id)target
selector: (SEL)selector
repeats: (bool)repeats;
/*!
* @brief Initializes an already allocated timer with the specified time
* interval.
*
* @param fireDate The date at which the timer should fire
* @param interval The time interval after which to repeat the timer, if it is
* a repeating timer
* @param target The target on which to call the selector
* @param selector The selector to call on the target
* @param object An object to pass when calling the selector on the target
* @param repeats Whether the timer repeats after it has been executed
* @return An initialized timer
*/
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
target: (id)target
selector: (SEL)selector
object: (id)object
repeats: (bool)repeats;
/*!
* @brief Initializes an already allocated timer with the specified time
|
︙ | | |
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
|
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
|
-
+
-
+
|
* target
* @param object2 The second object to pass when calling the selector on the
* target
* @param repeats Whether the timer repeats after it has been executed
* @return An initialized timer
*/
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
target: (id)target
selector: (SEL)selector
object: (id)object1
object: (id)object2
repeats: (bool)repeats;
#ifdef OF_HAVE_BLOCKS
/*!
* @brief Initializes an already allocated timer with the specified time
* interval.
*
* @param fireDate The date at which the timer should fire
* @param interval The time interval after which to repeat the timer, if it is
* a repeating timer
* @param repeats Whether the timer repeats after it has been executed
* @param block The block to invoke when the timer fires
* @return An initialized timer
*/
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
repeats: (bool)repeats
block: (of_timer_block_t)block;
#endif
/*!
* @brief Fires the timer, meaning it will execute the specified selector on the
* target.
|
︙ | | |
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
|
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
|
-
+
|
/*!
* @brief Returns the time interval in which the timer will repeat, if it is a
* repeating timer.
*
* @return The time interval in which the timer will repeat, if it is a
* repeating timer
*/
- (double)timeInterval;
- (of_time_interval_t)timeInterval;
#ifdef OF_HAVE_THREADS
/*!
* @brief Waits until the timer fired.
*/
- (void)waitUntilDone;
#endif
@end
|
Modified src/OFTimer.m
from [c568ad4130]
to [530e886394].
︙ | | |
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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
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
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
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
|
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
-
+
|
#import "OFInvalidArgumentException.h"
#import "autorelease.h"
#import "macros.h"
@implementation OFTimer
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
repeats: (bool)repeats
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
target: target
selector: selector
repeats: repeats] autorelease];
[[OFRunLoop currentRunLoop] addTimer: timer];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object
repeats: (bool)repeats
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
target: target
selector: selector
object: object
repeats: repeats] autorelease];
[[OFRunLoop currentRunLoop] addTimer: timer];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object1
object: (id)object2
repeats: (bool)repeats
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
target: target
selector: selector
object: object1
object: object2
repeats: repeats] autorelease];
[[OFRunLoop currentRunLoop] addTimer: timer];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
#ifdef OF_HAVE_BLOCKS
+ (instancetype)scheduledTimerWithTimeInterval: (double)interval
+ (instancetype)scheduledTimerWithTimeInterval: (of_time_interval_t)timeInterval
repeats: (bool)repeats
block: (of_timer_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
repeats: repeats
block: block] autorelease];
[[OFRunLoop currentRunLoop] addTimer: timer];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
#endif
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
repeats: (bool)repeats
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
target: target
selector: selector
repeats: repeats] autorelease];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object
repeats: (bool)repeats
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
target: target
selector: selector
object: object
repeats: repeats] autorelease];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
target: (id)target
selector: (SEL)selector
object: (id)object1
object: (id)object2
repeats: (bool)repeats
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
target: target
selector: selector
object: object1
object: object2
repeats: repeats] autorelease];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
#ifdef OF_HAVE_BLOCKS
+ (instancetype)timerWithTimeInterval: (double)interval
+ (instancetype)timerWithTimeInterval: (of_time_interval_t)timeInterval
repeats: (bool)repeats
block: (of_timer_block_t)block
{
void *pool = objc_autoreleasePoolPush();
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: interval];
OFDate *fireDate = [OFDate dateWithTimeIntervalSinceNow: timeInterval];
id timer = [[[self alloc] initWithFireDate: fireDate
interval: interval
interval: timeInterval
repeats: repeats
block: block] autorelease];
[timer retain];
objc_autoreleasePoolPop(pool);
return [timer autorelease];
}
#endif
- init
{
OF_INVALID_INIT_METHOD
}
- (instancetype)OF_initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
target: (id)target
selector: (SEL)selector
object: (id)object1
object: (id)object2
arguments: (uint8_t)arguments
repeats: (bool)repeats
{
|
︙ | | |
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
|
-
+
-
+
-
+
-
+
|
@throw e;
}
return self;
}
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
target: (id)target
selector: (SEL)selector
repeats: (bool)repeats
{
return [self OF_initWithFireDate: fireDate
interval: interval
target: target
selector: selector
object: nil
object: nil
arguments: 0
repeats: repeats];
}
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
target: (id)target
selector: (SEL)selector
object: (id)object
repeats: (bool)repeats
{
return [self OF_initWithFireDate: fireDate
interval: interval
target: target
selector: selector
object: object
object: nil
arguments: 1
repeats: repeats];
}
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
target: (id)target
selector: (SEL)selector
object: (id)object1
object: (id)object2
repeats: (bool)repeats
{
return [self OF_initWithFireDate: fireDate
interval: interval
target: target
selector: selector
object: object1
object: object2
arguments: 2
repeats: repeats];
}
#ifdef OF_HAVE_BLOCKS
- initWithFireDate: (OFDate*)fireDate
interval: (double)interval
interval: (of_time_interval_t)interval
repeats: (bool)repeats
block: (of_timer_block_t)block
{
self = [super init];
@try {
_fireDate = [fireDate retain];
|
︙ | | |
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
|
-
+
|
[_inRunLoop addTimer: self];
}
} @finally {
[self release];
}
}
- (double)timeInterval
- (of_time_interval_t)timeInterval
{
return _interval;
}
- (void)invalidate
{
_valid = false;
|
︙ | | |
Modified src/threading.h
from [60a577e8c2]
to [7bbaf6acd2].
︙ | | |
19
20
21
22
23
24
25
26
27
28
29
30
31
32
|
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
|
+
+
|
#if !defined(OF_HAVE_THREADS) || \
(!defined(OF_HAVE_PTHREADS) && !defined(_WIN32))
# error No threads available!
#endif
#include <math.h>
#import "OFObject.h"
#import "macros.h"
#if defined(OF_HAVE_PTHREADS)
# include <pthread.h>
typedef pthread_t of_thread_t;
typedef pthread_key_t of_tlskey_t;
typedef pthread_mutex_t of_mutex_t;
|
︙ | | |
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
|
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
|
-
+
|
return true;
#endif
}
static OF_INLINE bool
of_condition_timed_wait(of_condition_t *condition, of_mutex_t *mutex,
double timeout)
of_time_interval_t timeout)
{
#if defined(OF_HAVE_PTHREADS)
struct timespec ts;
ts.tv_sec = (time_t)timeout;
ts.tv_nsec = lrint((timeout - ts.tv_sec) * 1000000000);
|
︙ | | |