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

Method TryEnqueue

tensorflow/core/kernels/random_shuffle_queue_op.cc:127–162  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

125}
126
127void RandomShuffleQueue::TryEnqueue(const Tuple& tuple, OpKernelContext* ctx,
128 DoneCallback callback) {
129 CancellationManager* cm = ctx->cancellation_manager();
130 CancellationToken token = cm->get_cancellation_token();
131 bool already_cancelled;
132 {
133 mutex_lock l(mu_);
134 already_cancelled = !cm->RegisterCallback(
135 token, [this, cm, token]() { Cancel(kEnqueue, cm, token); });
136 if (!already_cancelled) {
137 enqueue_attempts_.emplace_back(
138 1, callback, ctx, cm, token,
139 [tuple, this](Attempt* attempt) EXCLUSIVE_LOCKS_REQUIRED(mu_) {
140 if (closed_) {
141 attempt->context->SetStatus(errors::Cancelled(
142 "RandomShuffleQueue '", name_, "' is closed."));
143 return kComplete;
144 }
145 if (queues_[0].size() < static_cast<size_t>(capacity_)) {
146 for (int i = 0; i < num_components(); ++i) {
147 queues_[i].push_back(PersistentTensor(tuple[i]));
148 }
149 return kComplete;
150 } else {
151 return kNoProgress;
152 }
153 });
154 }
155 }
156 if (!already_cancelled) {
157 FlushUnlocked();
158 } else {
159 ctx->SetStatus(errors::Cancelled("Enqueue operation was cancelled"));
160 callback();
161 }
162}
163
164/* static */
165Status RandomShuffleQueue::GetElementComponentFromBatch(

Callers

nothing calls this directly

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