Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Instantiate a background runloop in iOS

Use Case

I have a set of processes that each need to run on their own background thread at a certain execution rate (3 times a second, once every 10 seconds etc).

I believe CFRunLoop and/or NSRunLoop provide this functionality

Question

How do I create (in swift) a new background thread for which to execute a periodic tasks on?

like image 649
Jeef Avatar asked Oct 13 '15 14:10

Jeef


1 Answers

Old post but "background run loop" doesn't equal "background thread" nor does it mean "background queue". Usually there is only one run loop and that is the main thread's run loop. Other threads usually use this run loop but rarely have their own run loop (or their respective run loops are never readily available). To create a run loop for a thread that is not the main thread Apple has a guide and states when this should be done.

Also here is a nice guide I found on run loops in background threads.

like image 115
keji Avatar answered Oct 04 '22 05:10

keji