Reputation: 1519
I have an iOS app, where the UI is written in swift, but all the heavy work is done with a cross platform c++ library. I communicate with the c++ core from swift using a ObjC wrapper.
I wanted to parallelize the work that is happening in the c++ library, using the thread primitives that c++ provides.
But a piece of data is passed into the c++ library from the swift portion of the app, from within a block in a dispatch queue.
My question is, will those threads that I create within the c++ library be separate from the work queue in swift ? From what I understand, it will be. Is that the case ?
Are there any open-source projects which does something similar, or any pitfalls you see with this approach.
The C++ library is a requirement and I can't make it swift only.
Upvotes: 5
Views: 1010
Reputation: 804
will those threads that I create within the c++ library be separate from the work queue in swift ?
The answer is yes. I'm doing the same things for my app. For C++ library, I believe you will create threads with pthread_create()
POSIX call. As found in Apple's doc, POSIX threads are totally legal in iOS and the only way to create joinable threads.
Upvotes: 3