MCPcopy Create free account
hub / github.com/catboost/catboost / TryEnqueue

Method TryEnqueue

library/cpp/threading/chunk_queue/queue.h:293–311  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

291
292 template <typename TT>
293 bool TryEnqueue(TT&& value, ui64 tag) {
294 for (size_t i = 0; i < Concurrency; ++i) {
295 TQueueType& queue = Queues[i];
296 if (queue.WriteLock.IsLocked()) {
297 continue;
298 }
299 TTryGuard guard{queue.WriteLock};
300 if (!guard) {
301 continue;
302 }
303 TEntry* entry = queue.PrepareWrite();
304 Y_ASSERT(entry);
305 TTypeHelper::Write(&entry->Value, std::forward<TT>(value));
306 entry->Tag = tag;
307 queue.CompleteWrite();
308 return true;
309 }
310 return false;
311 }
312
313 TEntry* PrepareRead(size_t& index) {
314 TEntry* entry = nullptr;

Callers

nothing calls this directly

Calls 4

PrepareWriteMethod · 0.80
CompleteWriteMethod · 0.80
WriteFunction · 0.50
IsLockedMethod · 0.45

Tested by

no test coverage detected