File tree 1 file changed +13
-1
lines changed
1 file changed +13
-1
lines changed Original file line number Diff line number Diff line change @@ -613,19 +613,31 @@ namespace moodycamel
613
613
614
614
bool try_wait () AE_NO_TSAN
615
615
{
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;
616
620
return xSemaphoreTake (m_sema, 0 ) == pdTRUE;
617
621
}
618
622
619
623
bool timed_wait (std::uint64_t usecs) AE_NO_TSAN
620
624
{
621
625
std::uint64_t msecs = usecs / 1000 ;
622
626
TickType_t ticks = static_cast <TickType_t>(msecs / portTICK_PERIOD_MS);
627
+ if (ticks == 0 )
628
+ return try_wait ();
623
629
return xSemaphoreTake (m_sema, ticks) == pdTRUE;
624
630
}
625
631
626
632
void signal () AE_NO_TSAN
627
633
{
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);
629
641
assert (rc == pdTRUE);
630
642
AE_UNUSED (rc);
631
643
}
You can’t perform that action at this time.
0 commit comments