Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Question about a particular function. #5

Open
ghost opened this issue Oct 6, 2022 · 1 comment
Open

Question about a particular function. #5

ghost opened this issue Oct 6, 2022 · 1 comment

Comments

@ghost
Copy link

ghost commented Oct 6, 2022

Hi!

I found your code while looking for a lfq implementation in C.
Upon reading it, I am having some difficulty in understanding the following function.
It appears that you are using some ttl, but it's not clear to me why you are doing it.
Do you mind to share some insight?
Thank you

static void
__lfq_check_free(lfqueue_t *lfqueue) {
	lfq_time_t curr_time;
	if (__LFQ_BOOL_COMPARE_AND_SWAP(&lfqueue->in_free_mode, 0, 1)) {
		lfq_get_curr_time(&curr_time);
		lfqueue_cas_node_t *rtfree = lfqueue->root_free, *nextfree;
		while ( rtfree && (rtfree != lfqueue->move_free) ) {
			nextfree = rtfree->nextfree;
			if ( lfq_diff_time(curr_time, rtfree->_deactivate_tm) > 2) {
				//	printf("%p\n", rtfree);
				lfqueue->_free(lfqueue->pl, rtfree);
				rtfree = nextfree;
			} else {
				break;
			}
		}
		lfqueue->root_free = rtfree;
		__LFQ_BOOL_COMPARE_AND_SWAP(&lfqueue->in_free_mode, 1, 0);
	}
	__LFQ_SYNC_MEMORY();
}
@Taymindis
Copy link
Owner

hi @uvuxz ,

Yes it's TTL, due to memory balancing, we can't free immediately as it will cause memory crash. Batch Removing is a solution i can figure it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant