
Isn't there a deadlock issue with futures? suppose I have the following code: class A { int data; public: int getData() const { return data; } void someAction(B *b) { future<int> i = bind(b, &B::someAction, this); data = i.wait() + 1; } }; class B { int data; public: int someAction(A *a) { future<int> j = bind(a, &A::getData); return j.wait() + 1; } }; int main() { A *a = new A; B *b = new B; a->someAction(b); } The above contains a deadlock: class A builds a future 'i' in function 'someAction' over class B, then it waits for B's method 'someAction' to wait. class B, when its method 'someAction' is invoked, builds a future 'j' over method 'getData' of A...then it tries to evaluate 'j'. At this point, the instance of A is blocked waiting for B to finish its processing, and B waits for A to finish its processing, thus deadlocking the program. My question is: is this a real problem, and if so, how is it handled by boost::futures? Another way to introduce the deadlock is by mutual recursion using futures.