MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ck_epoch_dispatch

Function ck_epoch_dispatch

freebsd/contrib/ck/src/ck_epoch.c:359–394  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

357}
358
359static unsigned int
360ck_epoch_dispatch(struct ck_epoch_record *record, unsigned int e, ck_stack_t *deferred)
361{
362 unsigned int epoch = e & (CK_EPOCH_LENGTH - 1);
363 ck_stack_entry_t *head, *next, *cursor;
364 unsigned int n_pending, n_peak;
365 unsigned int i = 0;
366
367 head = ck_stack_batch_pop_upmc(&record->pending[epoch]);
368 for (cursor = head; cursor != NULL; cursor = next) {
369 struct ck_epoch_entry *entry =
370 ck_epoch_entry_container(cursor);
371
372 next = CK_STACK_NEXT(cursor);
373 if (deferred != NULL)
374 ck_stack_push_spnc(deferred, &entry->stack_entry);
375 else
376 entry->function(entry);
377
378 i++;
379 }
380
381 n_peak = ck_pr_load_uint(&record->n_peak);
382 n_pending = ck_pr_load_uint(&record->n_pending);
383
384 /* We don't require accuracy around peak calculation. */
385 if (n_pending > n_peak)
386 ck_pr_store_uint(&record->n_peak, n_peak);
387
388 if (i > 0) {
389 ck_pr_add_uint(&record->n_dispatch, i);
390 ck_pr_sub_uint(&record->n_pending, i);
391 }
392
393 return i;
394}
395
396/*
397 * Reclaim all objects associated with a record.

Callers 2

ck_epoch_reclaimFunction · 0.85
ck_epoch_poll_deferredFunction · 0.85

Calls 2

ck_stack_batch_pop_upmcFunction · 0.85
ck_stack_push_spncFunction · 0.85

Tested by

no test coverage detected