Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions lcrq.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,9 @@ static void lcrq_put(queue_t * q, handle_t * handle, uint64_t arg) {
CAS(&q->tail, &rq, nrq);
handle->next = NULL;
return;
} else {
// Save the ring queue for future use in the thread-local handle
handle->next = nrq;
}
continue;
}
Expand Down Expand Up @@ -228,6 +231,7 @@ static uint64_t lcrq_get(queue_t * q, handle_t * handle) {
void queue_register(queue_t * q, handle_t * th, int id)
{
hzdptr_init(&th->hzdptr, q->nprocs, 1);
th->next = NULL;
}

void enqueue(queue_t * q, handle_t * th, void * val)
Expand All @@ -239,6 +243,7 @@ void * dequeue(queue_t * q, handle_t * th)
{
return (void *) lcrq_get(q, th);
}

//By K
void handle_free(handle_t *h){
hzdptr_t *hzd = &h->hzdptr;
Expand All @@ -247,7 +252,11 @@ void handle_free(handle_t *h){
free(rlist[i]);
}
free(h->hzdptr.ptrs);
if (h->next != NULL){
free(h->next);
}
}

void queue_free(queue_t * q, handle_t * h){
RingQueue *rq = q->head;
while(rq){
Expand Down