Overview
Features
Download
Documentation
Community
Add-Ons & Services

Can args be coped to POCO threads, not sent via pointer?

A general discussion forum.

Can args be coped to POCO threads, not sent via pointer?

Postby oskar » 03 Nov 2009, 03:05

Sorry if the title sounds a bit disjointed, but I'm wondering if I can actually pass the values of the arguments to POCO threads, rather than just sending a pointer to them.

This is important because if I simply pass a pointer to the args, I always have to be careful that they don't fall out of scope and get demolished before the thread has time to receive them. I much prefer the Boost.Thread method below:

Code: Select all
void find_the_question(int the_answer);

boost::thread deep_thought_2(find_the_question,42);

I'm hoping that I won't have to use a far larger library just for this little functionality, so does anyone know if POCO supports it?
oskar
 
Posts: 1
Joined: 03 Nov 2009, 00:12

Re: Can args be coped to POCO threads, not sent via pointer?

Postby alex » 03 Nov 2009, 12:36

oskar wrote:I'm hoping that I won't have to use a far larger library just for this little functionality, so does anyone know if POCO supports it?


Thread::start takes either a reference to Runnable or pointer to Callable and a void*, so the answer is no. But I think your problem is not so difficult because you can make your own copy in the thread.
alex
 
Posts: 1115
Joined: 11 Jul 2006, 16:27
Location: United_States


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest

cron