mirror of https://github.com/ARMmbed/mbed-os.git
bigger equeue generation size and only increment when needed
to mitigate against generation clashpull/14405/head
parent
0e89f9d6d9
commit
3f9c734e1a
|
@ -61,8 +61,9 @@ struct equeue_event {
|
|||
typedef struct equeue {
|
||||
struct equeue_event *queue;
|
||||
unsigned tick;
|
||||
|
||||
uint16_t generation;
|
||||
bool break_requested;
|
||||
uint8_t generation;
|
||||
|
||||
unsigned char *buffer;
|
||||
unsigned npw2;
|
||||
|
|
|
@ -351,8 +351,8 @@ static struct equeue_event *equeue_dequeue(equeue_t *q, unsigned target)
|
|||
{
|
||||
equeue_mutex_lock(&q->queuelock);
|
||||
|
||||
// find all expired events and mark a new generation
|
||||
q->generation += 1;
|
||||
// find all expired events
|
||||
|
||||
if (equeue_tickdiff(q->tick, target) <= 0) {
|
||||
q->tick = target;
|
||||
}
|
||||
|
@ -370,6 +370,12 @@ static struct equeue_event *equeue_dequeue(equeue_t *q, unsigned target)
|
|||
|
||||
*p = 0;
|
||||
|
||||
/* we only increment the generation if events have been taken off the queue
|
||||
* as this is the only time cancellation may conflict with dequeueing */
|
||||
if (head) {
|
||||
q->generation += 1;
|
||||
}
|
||||
|
||||
equeue_mutex_unlock(&q->queuelock);
|
||||
|
||||
// reverse and flatten each slot to match insertion order
|
||||
|
|
Loading…
Reference in New Issue