开发者

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.

  1. the thread loop

  2. PushMessage (takes a custom class message and pushes onto queue)

  3. PopMessage (pops a message from the queue)

  4. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜