MCPcopy Create free account
hub / github.com/FastLED/FastLED / try_acquire_for

Method try_acquire_for

src/platforms/esp/32/semaphore_esp32.cpp.hpp:138–159  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

136template<ptrdiff_t LeastMaxValue>
137template<class Rep, class Period>
138bool CountingSemaphoreESP32<LeastMaxValue>::try_acquire_for(
139 const std::chrono::duration<Rep, Period>& rel_time) { // okay std namespace
140
141 if (mHandle == nullptr) {
142 return false;
143 }
144
145 // Convert duration to FreeRTOS ticks
146 auto ms = std::chrono::duration_cast<std::chrono::milliseconds>(rel_time); // okay std namespace
147 if (ms.count() <= 0) {
148 return try_acquire();
149 }
150 TickType_t ticks = pdMS_TO_TICKS(ms.count());
151 if (ticks == 0) {
152 ticks = 1;
153 }
154
155 SemaphoreHandle_t handle = static_cast<SemaphoreHandle_t>(mHandle);
156 BaseType_t result = xSemaphoreTake(handle, ticks);
157
158 return (result == pdTRUE);
159}
160
161template<ptrdiff_t LeastMaxValue>
162template<class Clock, class Duration>

Callers

nothing calls this directly

Calls 1

countMethod · 0.45

Tested by

no test coverage detected