MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / ComputeAsync

Method ComputeAsync

tensorflow/core/kernels/mutex_ops.cc:185–219  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

183
184 public:
185 void ComputeAsync(OpKernelContext* c, DoneCallback done) override {
186 Mutex* mutex = nullptr;
187 OP_REQUIRES_OK_ASYNC(
188 c,
189 LookupOrCreateResource<Mutex>(c, HandleFromInput(c, 0), &mutex,
190 [c](Mutex** ptr) {
191 *ptr = new Mutex(
192 c, HandleFromInput(c, 0).name());
193 return Status::OK();
194 }),
195 done);
196
197 Tensor* variant;
198 OP_REQUIRES_OK_ASYNC(c, c->allocate_output(0, TensorShape({}), &variant),
199 done);
200
201 mutex->AcquireAsync(
202 c, std::bind(
203 [c, variant, mutex](DoneCallback done_,
204 // End of bound arguments.
205 const Status& s,
206 Mutex::SharedLockReleaser&& lock) {
207 VLOG(2) << "Finished locking mutex " << mutex
208 << " with lock: " << lock.shared_lock.get()
209 << " status: " << s.ToString();
210 if (s.ok()) {
211 variant->scalar<Variant>()() = std::move(lock);
212 } else {
213 c->SetStatus(s);
214 }
215 mutex->Unref();
216 done_();
217 },
218 std::move(done), std::placeholders::_1, std::placeholders::_2));
219 }
220};
221
222class ConsumeMutexLockOp : public OpKernel {

Callers

nothing calls this directly

Calls 10

HandleFromInputFunction · 0.85
allocate_outputMethod · 0.80
AcquireAsyncMethod · 0.80
nameMethod · 0.65
TensorShapeClass · 0.50
getMethod · 0.45
ToStringMethod · 0.45
okMethod · 0.45
SetStatusMethod · 0.45
UnrefMethod · 0.45

Tested by

no test coverage detected