1CK_EPOCH_BARRIER(3)      BSD Library Functions Manual      CK_EPOCH_BARRIER(3)
2

NAME

4     ck_epoch_barrier — block until a grace period and all callbacks have been
5     dispatched
6

LIBRARY

8     Concurrency Kit (libck, -lck)
9

SYNOPSIS

11     #include <ck_epoch.h>
12
13     void
14     ck_epoch_barrier(ck_epoch_record_t *record);
15

DESCRIPTION

17     The ck_epoch_barrier(3) function will block the caller until a grace
18     period has been detected, according to the semantics of epoch reclama‐
19     tion.  Any objects requiring safe memory reclamation which are logically
20     deleted are safe for physical deletion following a call to
21     ck_epoch_barrier(3). This function will also dispatch all callbacks asso‐
22     ciated with epoch that were previously scheduled via ck_epoch_call(3).
23

EXAMPLE

25           #include <ck_epoch.h>
26           #include <ck_stack.h>
27           #include <stdlib.h>
28
29           /*
30            * epoch was previously initialized with ck_epoch_init.
31            * stack was previously initialized with ck_stack_init.
32            */
33           ck_epoch_t *epoch;
34           ck_stack_t *stack;
35
36           void
37           function(void)
38           {
39                   ck_epoch_record_t *record;
40                   ck_stack_entry_t *s;
41
42                   record = malloc(sizeof *record);
43                   ck_epoch_register(&epoch, record);
44
45                   /*
46                    * We are using an epoch section here to guarantee no
47                    * nodes in the stack are deleted while we are dereferencing
48                    * them. This is needed here because there are multiple writers.
49                    * If there was only one thread popping from the this stack,
50                    * then there is no need to ck_epoch_begin/ck_epoch_end.
51                    */
52                   ck_epoch_begin(record);
53
54                   /* Logically delete an object. */
55                   s = ck_stack_pop_upmc(stack);
56
57                   ck_epoch_end(record);
58
59                   /*
60                    * Wait until no threads could possibly have a reference to the
61                    * object we just popped (assume all threads are simply executing
62                    * ck_stack_pop_upmc).
63                    */
64                   ck_epoch_barrier(record);
65
66                   /* It is now safe to physically delete the object. */
67                   free(s);
68                   return;
69           }
70

RETURN VALUES

72     This function has no return value.
73

ERRORS

75     Behavior is undefined if the object pointed to by epoch is not a valid
76     epoch object. The object pointed to by record must have been previously
77     registered via ck_epoch_register(3).
78

SEE ALSO

80     ck_epoch_init(3), ck_epoch_register(3), ck_epoch_unregister(3),
81     ck_epoch_recycle(3), ck_epoch_poll(3), ck_epoch_synchronize(3),
82     ck_epoch_reclaim(3), ck_epoch_call(3), ck_epoch_begin(3), ck_epoch_end(3)
83
84     Additional information available at http://concurrencykit.org/
85
86                               September 2, 2012
Impressum