[Ovmsdev] Event task
Michael Balzer
dexter at expeedo.de
Sun Apr 8 15:27:38 HKT 2018
Am 07.04.2018 um 15:23 schrieb Michael Balzer:
> Another idea that can solve both issues: SignalEvent(event, data, [DoneCallback])
>
> DoneCallback(event, data) would be called by the EventTask after listener execution has finished. The callback can implement memory cleanup and/or synchronous
> processing (i.e. by a semaphore or task signal) as needed.
C++ now also has a nice lambda construct with very simple capturing of arbitrary scope parts by copy or reference. That enables nice inline callback definitions
like this:
char *data = strdup(message);
MyEvents.SignalEvent("simple.event", (void*)data, [data](){ free(data); });
…or…
SomeObject *clone = new SomeObject(original);
MyEvents.SignalEvent("object.event", (void*)clone, [clone](){ delete clone; });
Regards,
Michael
--
Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal
Fon 02333 / 833 5735 * Handy 0176 / 206 989 26
More information about the OvmsDev
mailing list