is it possible to call for a function from one thread, but run it on another?
is it possible to call for a function from one thread, but run it on another?
either you want:
1) to create a new thread which calls the function
so thread 1 comes to a point where it calls begin_thread(&my_func), which creates the new thread
2) or you want an existing thread to call the function
then your first thread somehow has to communicate with the second thread.
it is possible to pass a value to a thread upon creation. pass it a pointer to a queue structure, then
thread 1 calls
the_other_thread.get_action_queue.push(action); // push a new action into the action queue for the thread which should perform the action
and the other thread executes something like
of course it would be good getting rid of the active waiting part.Code:do forever { while(action_queue not empty) Action &a = action_queue.top(); a.perform(); // perform the action action_queue.pop(); } }
so that the thread suspends if the queue is empty and gets waken up if something is put into the queue
signature under construction
i didn't understand completely what u said, but it helped me getting to the solution (which is maybe exactly what u explained).
thanks.
lol, sry, i explained it pretty bad i know
still glad i could help ^^
signature under construction