MCPcopy Create free account
hub / github.com/Bareflank/hypervisor / push

Method push

lib/include/basic_queue_t.hpp:87–107  ·  view source on GitHub ↗

<!-- description --> @brief Pushes an element to the queue and returns bsl::errc_success. If the queue is full, returns bsl::errc_failure. <!-- inputs/outputs --> @param val the value to push to the queue @param sloc the source location of the push for debugging @return Returns bsl::errc_success on success, or bsl::errc_failure if the queue is full.

Source from the content-addressed store, hash-verified

85 /// bsl::errc_failure if the queue is full.
86 ///
87 [[nodiscard]] constexpr auto
88 push(T const &val, bsl::source_location const &sloc = bsl::here()) noexcept
89 -> bsl::errc_type
90 {
91 if (bsl::unlikely(this->full())) {
92 bsl::error() << "queue is full\n" << sloc;
93 return bsl::errc_failure;
94 }
95
96 *m_queue.at_if(m_head) = val;
97
98 ++m_head;
99 if (m_head >= N) {
100 m_head = {};
101 }
102 else {
103 bsl::touch();
104 }
105
106 return bsl::errc_success;
107 }
108
109 /// <!-- description -->
110 /// @brief Pops an element from the queue and returns

Callers 2

testsFunction · 0.80
mainFunction · 0.80

Calls 1

fullMethod · 0.95

Tested by 2

testsFunction · 0.64
mainFunction · 0.64