Hi, I’ve got an xpc service that is being handled by a specific thread that runs the following method :
upon c’tor, I start the xpc service in a new thread ;
class cppWrapperClass {
private:
std::thread t_;
NSXPCListener *listener_;
ServiceDelegateAlertsHandler *delegate_;
};
cppWrapperClass::cppWrapperClass() {
std::thread t_ = std::thread(&startService, this);
}
void startService() {
listener_ = [[NSXPCListener alloc] initWithMachServiceName:@"com.myapp.alerts"];
delegate_ = [ServiceDelegateAlertsHandler new];
listener_.delegate = delegate_;
[listener_ resume];
[[NSRunLoop currentRunLoop] run];
}
Now, i’d like to gracefully teardown the process before exiting.
So I’m looking for a way to terminate the thread, if it’s done directly from the wrapper destructor the process get crash with abort message, so I wonder if there’s any way to terminate the currentRunLoop from another thread in the process ?