SYTimer is a High performance library for timing. It provides you a chance to use it main runLoop or other runLoop in your next app.
Base on CFRunLoop Timer for iOS.
- All runLoop and runLoopMode Support.
- It's only created two runLoop timer when in main runLoop.
- It's based on priority queue wehn in main runLoop
- ThreadSpecificVariable.
- Heap and HeapItem.
The simplest use-case to setting an timer in main runLoop:
_timer = [SYTimer mainRunLoopTimerWithRunLoopMode:kCFRunLoopCommonModes block:^(SYTimer * _Nonnull) {
// do
}];
[_timer startRepeating:.5];
SYTimer will puted ther timer into the runLoopCommonModes heap and set runLoop timer next fire date.
other runLoop:
_otherRunLoopTimer = [[SYTimer alloc] initWithRunLoop:[SYRunLoop current] runLoopMode:kCFRunLoopCommonModes block:^(SYTimer * timer) {
// do
}];
[_otherRunLoopTimer startRepeating:.5];
Just created runLoop timer and added to current runLoop.
See SYHeap code. It's contained min-heap and max-heap, INCREASE-KEY, DECREASE-KEY. It's used just like NSArray.
A SYThreadSpecificVariable
is a variable that can be read and set like a normal variable except that it holds different variables per thread.
An object which it's packaged as SYHeapItem and store it in a heap which it's SYHeap.
- Add
pod 'SYTimer'
to your Podfile. - Run
pod install
orpod update
. - Import <SYTimer/SYTimer.h>.
This library requires iOS 10.0+
and Xcode 11.0+
.
SYTimer is provided under the MIT license. See LICENSE file for details.