I have a C API that is a queue used to pass messages between threads. I want to pass a std::function<void()>
through it, but to do that, I need to degrade it to a POD chunk of data of constant length.
The std::function
will be mostly from C++11 lambdas and will capture by reference or copy. I can use the heap from both sides of the C-queue.
The queue itself is a FreeRTOS queue and this is in embedded. There is some discussion about passing C++ish things through the queue on their forums. It mostly says it's ok if it's a POD or is trivially constructable.
Currently I'm passing around struct { void (*fp)(void*); void* context; }
, but I'd like something a bit better.
Any idea how to do this?
Aucun commentaire:
Enregistrer un commentaire