Re: How to return data from a thread?



Kevin Brooks wrote:

--- Bo Lorentsen <bl lue dk> wrote:

Kevin Brooks wrote:

I want to know how to return data from a thread.


This has little to do with Gtkmm, but the hint could
be to use a pipe or a semaphore to indicate thread termination, and store the returned data on the haep, as the heap memory are shared between
threads.

Hope this helps :-)

/BL

Hi Bo,

Thank you for your reply and suggestion.

According to the documentation about Glib::Thread
class(http://www.gtkmm.org/docs/glibmm-2.4/docs/reference/html/classGlib_1_1Thread.html),
there is a statement saying that "if you want to
return any data from your thread you can pass an
additional output argument to the thread's entry
slot".

I don't quite understand what it means. Is anyone out
there know how to do it?

Thanks

Kevin






		
____________________________________________________
Start your day with Yahoo! - make it your home page http://www.yahoo.com/r/hs
_______________________________________________
gtkmm-list mailing list
gtkmm-list gnome org
http://mail.gnome.org/mailman/listinfo/gtkmm-list

Say you wish to output some character data. You would pass the address of a character pointer to your thread as a formal parameter to your thread entry slot. Then somewhere during your thread's execution dynamically allocate some memory using the address of that character pointer and then memcpy or strcpy the character to that memory before terminating the thread. Make sure that you de-allocate the memory after utilizing the returned data.

Bob



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]