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

Method TryEnqueue

tensorflow/core/kernels/fifo_queue.cc:50–85  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

48}
49
50void FIFOQueue::TryEnqueue(const Tuple& tuple, OpKernelContext* ctx,
51 DoneCallback callback) {
52 CancellationManager* cm = ctx->cancellation_manager();
53 CancellationToken token = cm->get_cancellation_token();
54 bool already_cancelled;
55 {
56 mutex_lock l(mu_);
57 already_cancelled = !cm->RegisterCallback(
58 token, [this, cm, token]() { Cancel(kEnqueue, cm, token); });
59 if (!already_cancelled) {
60 enqueue_attempts_.emplace_back(
61 1, callback, ctx, cm, token,
62 [tuple, this](Attempt* attempt) EXCLUSIVE_LOCKS_REQUIRED(mu_) {
63 if (closed_) {
64 attempt->context->SetStatus(
65 errors::Cancelled("FIFOQueue '", name_, "' is closed."));
66 return kComplete;
67 }
68 if (queues_[0].size() < static_cast<size_t>(capacity_)) {
69 for (int i = 0; i < num_components(); ++i) {
70 queues_[i].push_back(PersistentTensor(tuple[i]));
71 }
72 return kComplete;
73 } else {
74 return kNoProgress;
75 }
76 });
77 }
78 }
79 if (!already_cancelled) {
80 FlushUnlocked();
81 } else {
82 ctx->SetStatus(errors::Cancelled("Enqueue operation was cancelled"));
83 callback();
84 }
85}
86
87/* static */
88Status FIFOQueue::GetElementComponentFromBatch(const FIFOQueue::Tuple& tuple,

Callers 1

ComputeAsyncMethod · 0.45

Calls 12

CancelledFunction · 0.85
num_componentsFunction · 0.85
PersistentTensorClass · 0.85
callbackFunction · 0.85
EXCLUSIVE_LOCKS_REQUIREDFunction · 0.50
cancellation_managerMethod · 0.45
RegisterCallbackMethod · 0.45
emplace_backMethod · 0.45
SetStatusMethod · 0.45
sizeMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected