combine boost::thread(or any) into iphone's main thread?
I have a boost based thread(let's call it T-thread) separate from the iphone's main thread.
This custom T-thread talks to yet other thread开发者_运维技巧s using custom message objects.The thing is iphone's main thread(UI thread) and this T-thread don't need to be threaded to each other. And having separate threads makes my life miserable having to think over thread safety.
I'd like to combine the main thread and T-thread but can't figure out the basic strategy or not sure if this can be done.
My custom thread class (using boost::thread) has 4 methods.
the thread loop
PushMessage (takes a custom class message and pushes onto queue)
PopMessage (pops a message from the queue)
Dispatch (Actual work)
In some way, I need to incorporate the above 4 methods into the main thread.
Any suggestion will be appreciated. Thank you.umm, maybe easier than i worried.
PerformSelectorOnMainThread can emulate push/pop.
Just need to make a static object to execute the 'selector' so that main loop can access the object all the time.
精彩评论