} else {
examples.RandomShuffle();
}
- mutex mu;
- Status train_step_status GUARDED_BY(mu);
+ struct {
+ mutex mu;
+ Status value GUARDED_BY(mu);
+ } train_step_status;
std::atomic<std::int64_t> atomic_index(-1);
auto train_step = [&](const int64 begin, const int64 end) {
// The static_cast here is safe since begin and end can be at most
const Status conversion_status =
options.loss_updater->ConvertLabel(&example_label);
if (!conversion_status.ok()) {
- mutex_lock l(mu);
- train_step_status = conversion_status;
+ mutex_lock l(train_step_status.mu);
+ train_step_status.value = conversion_status;
// Return from this worker thread - the calling thread is
// responsible for checking context status and returning on error.
return;
Shard(worker_threads.num_threads, worker_threads.workers,
examples.num_examples(), kCostPerUnit, train_step);
- OP_REQUIRES_OK(context, train_step_status);
+ mutex_lock l(train_step_status.mu);
+ OP_REQUIRES_OK(context, train_step_status.value);
}
} // namespace