I am making a simple template class for communication with two thread in C++0x, using the promise and future.
My class make a channel to communicate thread with the main program and another channel to allow the child thread to initiate communication with the parent thread (or main program).
What do you mean by "run cycle again"?
Are you saying you're instantiating another thread, which coexists with *t?
OR
Are you saying you run the second execution of the entire program?
If you're instantiating another thread which operates on myVar, post the modified code and let's see what changes you've made.
Excuse my bad English.
I'm speaking about the while loop in myAsyncFun.
The first time the loop executes, it works well.
But the second time, when for the second time the statement is executed:
I don't have <future> installed on my machine, so I'm afraid I can't help debug your program.
From my personal experiences, the problem is usually illegal access of memory that doesn't belong to your thread. It happens more than 80% of the time when I get a seg fault.
Why don't you cout the value of r? Since your thread is going to increment r, you *might* get an idea of the execution order/flow by looking at the r values on terminal.