ck_epoch_recycle(3) return an epoch record that may be used by caller

LIBRARY

Concurrency Kit (libck, -lck)

SYNOPSIS

In ck_epoch.h Ft ck_epoch_record_t * Fn ck_epoch_recycle ck_epoch_t *epoch

DESCRIPTION

The Fn ck_epoch_recycle 3 function attempts to return an unused epoch record object for use by the caller. These epoch records were associated with previous calls to the Fn ck_epoch_unregister 3 function.

EXAMPLE

#include <ck_epoch.h>
#include <stdlib.h>
/*
 * epoch was previously initialized with ck_epoch_init.
 */
ck_epoch_t *epoch;
void
function(void)
{
        ck_epoch_record_t *record;
        record = ck_epoch_recycle(&epoch);
        if (record == NULL) {
                record = malloc(sizeof *record);
                if (record == NULL)
                        return;
                ck_epoch_register(&epoch, record);
        }
        /*
         * After we are done, we will unregister the record so it
         * can be used by other new participants in the epoch system
         * provided by the object pointed to by "epoch".
         */
        ck_epoch_unregister(&epoch, record);
        return;
}

RETURN VALUES

This function returns a pointer to a ck_epoch_record_t object. If no unused record was found to be associated with the object pointed to by Fa epoch , then the function will return NULL.

ERRORS

Behavior is undefined if the object pointed to by Fa epoch is not a valid epoch object.