mirror of
https://github.com/Swiftgram/Telegram-iOS.git
synced 2025-09-10 14:35:42 +00:00
Create CFRunLoopSourceContext via calloc
This commit is contained in:
parent
d1756baae7
commit
14b9df30a3
@ -9,6 +9,7 @@
|
|||||||
#import "ASRunLoopQueue.h"
|
#import "ASRunLoopQueue.h"
|
||||||
#import "ASThread.h"
|
#import "ASThread.h"
|
||||||
|
|
||||||
|
#import <cstdlib>
|
||||||
#import <deque>
|
#import <deque>
|
||||||
|
|
||||||
static void runLoopSourceCallback(void *info) {
|
static void runLoopSourceCallback(void *info) {
|
||||||
@ -44,9 +45,11 @@ static void runLoopSourceCallback(void *info) {
|
|||||||
|
|
||||||
// It is not guaranteed that the runloop will turn if it has no scheduled work, and this causes processing of
|
// It is not guaranteed that the runloop will turn if it has no scheduled work, and this causes processing of
|
||||||
// the queue to stop. Attaching a custom loop source to the run loop and signal it if new work needs to be done
|
// the queue to stop. Attaching a custom loop source to the run loop and signal it if new work needs to be done
|
||||||
CFRunLoopSourceContext runLoopSourceContext = {0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, &runLoopSourceCallback};
|
CFRunLoopSourceContext *runLoopSourceContext = (CFRunLoopSourceContext *)calloc(1, sizeof(CFRunLoopSourceContext));
|
||||||
_runLoopSource = CFRunLoopSourceCreate(NULL, 0, &runLoopSourceContext);
|
runLoopSourceContext->perform = runLoopSourceCallback;
|
||||||
|
_runLoopSource = CFRunLoopSourceCreate(NULL, 0, runLoopSourceContext);
|
||||||
CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes);
|
CFRunLoopAddSource(runloop, _runLoopSource, kCFRunLoopCommonModes);
|
||||||
|
free(runLoopSourceContext);
|
||||||
}
|
}
|
||||||
return self;
|
return self;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user