Difference between the .call and .event classes of EventQueue

Hello,

I’m currently trying to understand event queues but I’m confused about the difference between the .event() and .call() methods, especially in combination with something like a Ticker.

Could someone explain me the difference between the two methods and when to use one or the other?

Hi,

From the EventQueue API tutorial it looks like that if you want to add an event inside of a function use .call. If you want to add event when interrupt happened use .event. Look at
https://os.mbed.com/docs/mbed-os/v5.14/tutorials/the-eventqueue-api.html

.call calls event from event queue. If you used this inside of interrupt it calls the event after interrupt is handled and new interrupt can happened while running the event. Without .call for example time taking printf blocks everything if happened inside of interrupt.
→ use .call if you want to trigger something in interrupt but it is not time critical

.event constructs an event bound to the specified event queue. The specified callback acts as the target for the event and is executed in the context of the event queue’s dispatch loop once posted.

Not complete clear. I recommended you to do some test.

Regards,
Pekka

1 Like

may we say?
call is async
event is sync

I was also wondering why .call accepts lambda functions as argument, but .event does not.

I have to say that even after working a few months with Mbed OS, I haven’t completely understood the difference between these two functions. They seem to do the same thing, but I’ve noticed that .event and .call don’t behave the same. For example, using .event() would trigger an EventQueue overflow after a few minutes while .call was working fine with the exact same arguments. Is there a difference between .event and .call in how Mbed handles the Threads that run the EventQueue somehow?

1 Like