@@ -86,7 +86,7 @@ class UserAllocatedEvent<F, void(ArgTs...)> {
86
86
* @param f Function to execute when the event is dispatched
87
87
* @param args Arguments to bind to the callback
88
88
*/
89
- constexpr UserAllocatedEvent (F f, ArgTs... args) : _e(get_default_equeue_event()), _c(f, args...), _equeue(), _post_ref()
89
+ constexpr UserAllocatedEvent (F f, ArgTs... args) : _e(get_default_equeue_event()), _c(f, args...), _delay(), _period(- 1 ), _equeue(), _post_ref()
90
90
{
91
91
}
92
92
@@ -100,7 +100,7 @@ class UserAllocatedEvent<F, void(ArgTs...)> {
100
100
* @param f Function to execute when the event is dispatched
101
101
* @param args Arguments to bind to the callback
102
102
*/
103
- constexpr UserAllocatedEvent (EventQueue *queue, F f, ArgTs... args) : _e(get_default_equeue_event()), _c(f, args...), _equeue(&queue->_equeue), _post_ref()
103
+ constexpr UserAllocatedEvent (EventQueue *queue, F f, ArgTs... args) : _e(get_default_equeue_event()), _c(f, args...), _delay(), _period(- 1 ), _equeue(&queue->_equeue), _post_ref()
104
104
{
105
105
}
106
106
@@ -215,7 +215,7 @@ class UserAllocatedEvent<F, void(ArgTs...)> {
215
215
void delay (int delay)
216
216
{
217
217
MBED_ASSERT (!_post_ref);
218
- equeue_event_delay (&_e + 1 , delay) ;
218
+ _delay = delay;
219
219
}
220
220
221
221
/* * Configure the period of an event
@@ -225,7 +225,7 @@ class UserAllocatedEvent<F, void(ArgTs...)> {
225
225
void period (int period)
226
226
{
227
227
MBED_ASSERT (!_post_ref);
228
- equeue_event_period (&_e + 1 , period) ;
228
+ _period = period;
229
229
}
230
230
231
231
/* * Cancels posted event
@@ -251,6 +251,8 @@ class UserAllocatedEvent<F, void(ArgTs...)> {
251
251
friend class EventQueue ;
252
252
struct equeue_event _e;
253
253
C _c;
254
+ int _delay;
255
+ int _period;
254
256
struct equeue *_equeue;
255
257
uint8_t _post_ref;
256
258
@@ -260,17 +262,22 @@ class UserAllocatedEvent<F, void(ArgTs...)> {
260
262
return false ;
261
263
}
262
264
core_util_atomic_incr_u8 (&_post_ref, 1 );
265
+ equeue_event_delay (&_e + 1 , _delay);
266
+ equeue_event_period (&_e + 1 , _period);
263
267
equeue_post_user_allocated (_equeue, &EventQueue::function_call<C>, &_e);
264
268
return true ;
265
269
}
266
270
267
271
bool post_on (EventQueue *queue)
268
272
{
273
+ MBED_ASSERT (queue);
269
274
if (_post_ref) {
270
275
return false ;
271
276
}
272
277
_equeue = &(queue->_equeue );
273
278
core_util_atomic_incr_u8 (&_post_ref, 1 );
279
+ equeue_event_delay (&_e + 1 , _delay);
280
+ equeue_event_period (&_e + 1 , _period);
274
281
equeue_post_user_allocated (_equeue, &EventQueue::function_call<C>, &_e);
275
282
return true ;
276
283
}
0 commit comments