Skip to content

Commit b851c07

Browse files
committed
update compile
1 parent f43be75 commit b851c07

File tree

2 files changed

+21
-23
lines changed

2 files changed

+21
-23
lines changed

paddle/fluid/framework/threadpool.h

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ limitations under the License. */
2828
namespace paddle {
2929
namespace framework {
3030

31+
struct ExceptionHandler {
32+
mutable std::future<std::unique_ptr<platform::EnforceNotMet>> future_;
33+
explicit ExceptionHandler(
34+
std::future<std::unique_ptr<platform::EnforceNotMet>>&& f)
35+
: future_(std::move(f)) {}
36+
void operator()() const {
37+
auto ex = this->future_.get();
38+
if (ex != nullptr) {
39+
LOG(FATAL) << "The exception is thrown inside the thread pool. You "
40+
"should use RunAndGetException to handle the exception.\n"
41+
"The default exception handler is LOG(FATAL)."
42+
<< ex->what();
43+
}
44+
}
45+
};
46+
3147
// ThreadPool maintains a queue of tasks, and runs them using a fixed
3248
// number of threads.
3349
class ThreadPool {
@@ -87,22 +103,6 @@ class ThreadPool {
87103
void Wait();
88104

89105
private:
90-
struct ExceptionHandler {
91-
mutable std::future<std::unique_ptr<platform::EnforceNotMet>> future_;
92-
explicit ExceptionHandler(
93-
std::future<std::unique_ptr<platform::EnforceNotMet>>&& f)
94-
: future_(std::move(f)) {}
95-
void operator()() const {
96-
auto ex = this->future_.get();
97-
if (ex != nullptr) {
98-
LOG(FATAL) << "The exception is thrown inside the thread pool. You "
99-
"should use RunAndGetException to handle the exception.\n"
100-
"The default exception handler is LOG(FATAL)."
101-
<< ex->what();
102-
}
103-
}
104-
};
105-
106106
DISABLE_COPY_AND_ASSIGN(ThreadPool);
107107

108108
// If the task queue is empty and avaialbe is equal to the number of

paddle/fluid/operators/detail/grpc_client.cc

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,7 @@ bool RPCClient::AsyncSendVariable(const std::string& ep,
3333
const framework::Scope* p_scope = &scope;
3434
const auto ch = GetChannel(ep_val);
3535

36-
framework::AsyncIO([var_name_val, p_ctx, ep_val, p_scope, time_out, ch,
37-
this] {
36+
framework::Async([var_name_val, p_ctx, ep_val, p_scope, time_out, ch, this] {
3837
auto* var = p_scope->FindVar(var_name_val);
3938

4039
::grpc::ByteBuffer req;
@@ -89,8 +88,7 @@ bool RPCClient::AsyncGetVariable(const std::string& ep,
8988
const framework::Scope* p_scope = &scope;
9089
const auto ch = GetChannel(ep_val);
9190

92-
framework::AsyncIO([var_name_val, ep_val, p_scope, p_ctx, time_out, ch,
93-
this] {
91+
framework::Async([var_name_val, ep_val, p_scope, p_ctx, time_out, ch, this] {
9492
// prepare input
9593
sendrecv::VariableMessage req;
9694
req.set_varname(var_name_val);
@@ -133,8 +131,8 @@ bool RPCClient::AsyncPrefetchVariable(const std::string& ep,
133131
const framework::Scope* p_scope = &scope;
134132
const auto ch = GetChannel(ep_val);
135133

136-
framework::AsyncIO([in_var_name_val, out_var_name_val, ep_val, p_scope, p_ctx,
137-
time_out, ch, this] {
134+
framework::Async([in_var_name_val, out_var_name_val, ep_val, p_scope, p_ctx,
135+
time_out, ch, this] {
138136
auto* var = p_scope->FindVar(in_var_name_val);
139137

140138
::grpc::ByteBuffer req;
@@ -197,7 +195,7 @@ bool RPCClient::Wait() {
197195
std::vector<std::future<void>> waits(req_count_);
198196

199197
for (int i = 0; i < req_count_; i++) {
200-
waits[i] = framework::AsyncIO([i, &a, this] { a[i] = Proceed(); });
198+
waits[i] = framework::Async([i, &a, this] { a[i] = Proceed(); });
201199
}
202200

203201
for (int i = 0; i < req_count_; i++) {

0 commit comments

Comments
 (0)