(responding to Runtime only) I will reply to Wayne's email this morning, and follow it up with a message to dev regarding the recent eventq changes. I just wanted to send this note so no one spends time writing a response.
Thanks, Chris On Fri, Nov 04, 2016 at 01:08:50PM +0000, Wayne Keenan wrote: > sorry for the typo'ed subject and also these corrections are required: > > In the first post example this line: > my_event(&MY_EVENT_QUEUE, my_event); > should be: > os_eventq_put(&MY_EVENT_QUEUE, my_event); > > > In the second post example this line: > > rc = my_event(&MY_EVENT_QUEUE, OS_EVENT_T_PERUSER+1, arg ); //*1 > > > should read: > > rc = os_eventq_put(&MY_EVENT_QUEUE, OS_EVENT_T_PERUSER+1, arg ); //*1 > > > > All the best > Wayne > > On 4 November 2016 at 12:57, Wayne Keenan <wayne.kee...@gmail.com> wrote: > > > Hi, > > > > I had to move from the commonly found 'statically allocated' os_event > > usage pattern to something dynamic. > > > > This is what I'm using: > > > > // Post event: > > > > struct os_event* my_event = (struct os_event > > *)os_memblock_get(&bleprph_mbuf_mpool); > > > > if (!my_event) { > > // TODO: scream loudly > > return; > > } > > my_event->ev_queued = 0; > > my_event->ev_arg = arg; > > my_event->ev_type=OS_EVENT_T_PERUSER+1; // *1 > > my_event(&MY_EVENT_QUEUE, my_event); > > > > > > > > // Poll handler: > > > > case OS_EVENT_T_PERUSER+1: > > my_data = ev->ev_arg; > > os_eventq_remove(&btask_evq, ev); > > os_memblock_put(&task_mbuf_mpool, ev); //* 2 > > process_data(my_data); > > break; > > > > > > This seems to work and will fail quickly (reset) if step *2 isn't > > performed, but I have some questions. > > > > 1. Is this really correct? I've not seen it in the samples or the docs. > > 2. The samples and docs didn't make *2 obvious, e.g. who owns the memory > > pool. > > 3. Would it be better if the Task didn't care which pool the memory came > > from? i.e. inter task events. > > 4. I've assumed OS_EVENT_T_PERUSER+n is a valid thing todo, is it? until > > what n? is there a documented range limit? > > > > > > It would be nice to have the API that perhaps look something like this: > > > > // Post: > > rc = my_event(&MY_EVENT_QUEUE, OS_EVENT_T_PERUSER+1, arg ); //*1 > > if (rc) { > > // TODO: scream loudly > > return; > > } > > > > > > At *1 a default application pool, registered with the OS, is used (which > > would require additional API and setup in the application main startup) > > > > > > // Poll: > > struct os_event ev; > > > > os_eventq_get(&task_evq, &ev); // *1 > > > > switch (ev->ev_type) { > > case OS_EVENT_T_PERUSER+1: > > my_data = ev->ev_arg; > > process_data(my_data); > > break; > > } > > > > > > At *1 the event data is copied and the event itself is released by ' > > os_eventq_get' > > > > > > All the best > > Wayne > >