I will start out noting that I’m using MBedOS 5.12. I would like to upgrade but at the moment I cannot.
I am making calls to a library of functions from two different threads. They must be executed serially as the library is not reentrant. I am already making one of those calls periodically using EventQueue::call_every
which works fine since the function doesn’t return a value nor does it set information I need continue my processing. However, some of the functions use pointers passed in and return a status.
I need to
- Wait until the call completes
- Respond to the returned status
- Depending on the status, use the values stored by the function call in provided pointers
The EventQueue
works great for queuing up the function calls but it doesn’t provide a way to verify if the function is complete. Depending on how I queue the function call, I can determine if the function has been dispatched but not when it is complete.
Am I mistaken in assuming EventQueue
executes queued functions serially and not in parallel or in some form of task sharing? I.e., I’m just checking that an EventQueue
executes in a single thread.
I cannot modify the library so I’m stuck managing this external to the function calls. Using an Event
and associating it with a queue seems promising but I cannot get my head around how to set the value – I think it is replacing a function call and instead pointing a value that is dequeued and sent to the provided callback function. I really just want to be able to supply a callback to the queue that receives the value returned by the queued function call. I really don’t want to create a templatized class since EventQueue already has done that for me.
Is there a way to get the return value of the function call using EventQueue
or some other similar class?