1 #ifndef CAFFE2_NET_ASYNC_TASK_FUTURE_H 2 #define CAFFE2_NET_ASYNC_TASK_FUTURE_H 5 #include <condition_variable> 29 bool IsCompleted()
const;
31 bool IsFailed()
const;
33 std::string ErrorMessage()
const;
39 void SetCompleted(
const char* err_msg =
nullptr);
44 mutable std::mutex mutex_;
45 mutable std::condition_variable cv_completed_;
46 std::atomic<bool> completed_;
47 std::atomic<bool> failed_;
49 std::vector<std::function<void(const AsyncTaskFuture*)>> callbacks_;
51 struct ParentCounter {
52 explicit ParentCounter(
int init_parent_count)
53 : init_parent_count_(init_parent_count),
54 parent_count(init_parent_count),
55 parent_failed(
false) {}
58 std::unique_lock<std::mutex> lock(err_mutex);
59 parent_count = init_parent_count_;
60 parent_failed =
false;
64 const int init_parent_count_;
65 std::atomic<int> parent_count;
67 std::atomic<bool> parent_failed;
71 std::unique_ptr<ParentCounter> parent_counter_;
76 #endif // CAFFE2_NET_ASYNC_TASK_FUTURE_H A global dictionary that holds information about what Caffe2 modules have been loaded in the current ...