use weak_ptr and tr1::function and tr1::bind to manage resources