File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -613,19 +613,31 @@ namespace moodycamel
613613
614614 bool try_wait () AE_NO_TSAN
615615 {
616+ // Note: In an ISR context, if this causes a task to unblock,
617+ // the caller won't know about it
618+ if (xPortIsInsideInterrupt ())
619+ return xSemaphoreTakeFromISR (m_sema, NULL ) == pdTRUE;
616620 return xSemaphoreTake (m_sema, 0 ) == pdTRUE;
617621 }
618622
619623 bool timed_wait (std::uint64_t usecs) AE_NO_TSAN
620624 {
621625 std::uint64_t msecs = usecs / 1000 ;
622626 TickType_t ticks = static_cast <TickType_t>(msecs / portTICK_PERIOD_MS);
627+ if (ticks == 0 )
628+ return try_wait ();
623629 return xSemaphoreTake (m_sema, ticks) == pdTRUE;
624630 }
625631
626632 void signal () AE_NO_TSAN
627633 {
628- BaseType_t rc = xSemaphoreGive (m_sema);
634+ // Note: In an ISR context, if this causes a task to unblock,
635+ // the caller won't know about it
636+ BaseType_t rc;
637+ if (xPortIsInsideInterrupt ())
638+ rc = xSemaphoreGiveFromISR (m_sema, NULL );
639+ else
640+ rc = xSemaphoreGive (m_sema);
629641 assert (rc == pdTRUE);
630642 AE_UNUSED (rc);
631643 }
You can’t perform that action at this time.
0 commit comments