<html><head><meta http-equiv="Content-Type" content="text/html charset=utf-8"></head><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;" class="">I’ve implemented this (along the lines of what we talked about).<div class=""><br class=""></div><div class="">I think the free could be done in the way you suggest, or alternatively I have provided an EventStdFree that you can just tack on the end of the SignalEvent call. It just frees the data.</div><div class=""><br class=""></div><div class="">I’ve also provided a variant of SignalEvent that can be provided with a size_t for the data. That variant clones the data, and defines a cleanup function to free it.</div><div class=""><br class=""></div><div class="">Implementation seems ok. Stack usage looks fine:</div><div class=""><br class=""></div><blockquote style="margin: 0 0 0 40px; border: none; padding: 0px;" class=""><div class=""><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">OVMS# module tasks</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">Number of Tasks = 17 Stack: Now Max Total Heap 32-bit SPIRAM</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFAFB48 1 Blk esp_timer 388 580 4096 38080 644 21756</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFBDD5C 2 Blk eventTask 440 1768 4608 0 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFBFB58 3 Blk OVMS Events 436 3780 6144 86916 0 6800</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFC4794 4 Blk OVMS CanRx 432 432 1024 0 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFC884C 5 Blk ipc0 392 440 1024 7776 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFC8E4C 6 Blk ipc1 392 440 1024 12 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFCAC74 9 Rdy IDLE 368 496 1024 0 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFCB208 10 Rdy IDLE 356 484 1024 0 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFCBF9C 11 Blk Tmr Svc 392 680 3072 0 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFCF9F4 16 Blk tiT 492 2348 3072 740 0 5868</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFD5CA4 17 Blk OVMS SIMCOM 464 2496 4096 4400 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFD7C54 18 Blk wifi 432 2304 4096 304 0 1708</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFDA3EC 19 Blk pmT 408 1672 2560 0 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFDAA04 20 Blk OVMS Vehicle 452 452 3072 0 0 0</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFDEC24 21 Rdy OVMS Console 760 2600 6144 20 15488 12000</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFDF604 22 Blk mdns 412 1732 4096 104 0 4</span></font></div><div class=""><font face="Andale Mono" class=""><span style="font-size: 14px;" class="">3FFE3118 23 Blk OVMS NetMan 728 2392 7168 1528 0 68</span></font></div></div></blockquote><div class=""><br class=""></div><div class="">It solves my problem with scripts on SD CARD mount for v3.1 hardware.</div><div class=""><br class=""></div><div class="">I’ve committed it as is, and fixed most uses of SignalEvent I could find. There are some in the canopen and RT code that I’ve left for @michael.</div><div class=""><br class=""></div><div class="">I don’t think notifications will work correctly now because they seem to rely on the SignalEvent returning after all the handlers have processed the event (no longer the case). I’m guessing that needs to be changed to use the DoneFN as a callback.</div><div class=""><br class=""></div><div class="">Can you guys have a review of it? I must prefer to run this stuff in one task (Event), but this is a large change and could break a bunch of stuff.</div><div class=""><br class=""></div><div class="">Regards, Mark.</div><div class=""><br class=""></div><div class=""><div><blockquote type="cite" class=""><div class="">On 8 Apr 2018, at 3:27 PM, Michael Balzer <<a href="mailto:dexter@expeedo.de" class="">dexter@expeedo.de</a>> wrote:</div><br class="Apple-interchange-newline"><div class=""><div class=""><br class="">Am 07.04.2018 um 15:23 schrieb Michael Balzer:<br class=""><blockquote type="cite" class="">Another idea that can solve both issues: SignalEvent(event, data, [DoneCallback])<br class=""><br class="">DoneCallback(event, data) would be called by the EventTask after listener execution has finished. The callback can implement memory cleanup and/or synchronous<br class="">processing (i.e. by a semaphore or task signal) as needed.<br class=""></blockquote><br class="">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<br class="">like this:<br class=""><br class=""> char *data = strdup(message);<br class=""> MyEvents.SignalEvent("simple.event", (void*)data, [data](){ free(data); });<br class=""><br class="">…or…<br class=""><br class=""> SomeObject *clone = new SomeObject(original);<br class=""> MyEvents.SignalEvent("object.event", (void*)clone, [clone](){ delete clone; });<br class=""><br class="">Regards,<br class="">Michael<br class=""><br class="">-- <br class="">Michael Balzer * Helkenberger Weg 9 * D-58256 Ennepetal<br class="">Fon 02333 / 833 5735 * Handy 0176 / 206 989 26<br class=""><br class=""><br class="">_______________________________________________<br class="">OvmsDev mailing list<br class=""><a href="mailto:OvmsDev@lists.openvehicles.com" class="">OvmsDev@lists.openvehicles.com</a><br class="">http://lists.openvehicles.com/mailman/listinfo/ovmsdev<br class=""></div></div></blockquote></div><br class=""></div></body></html>