6 This is an example about how to specify the correctness of the
7 read-copy-update synchronization mechanism.
10 // Properties to check:
13 typedef void* (*read_func_ptr_t)(void*);
15 template <typename Type>
22 static bool equals(void *ptr1, void *ptr2) {
24 // Return if the two data instances pointed to equals to each
40 @Commit_point_set: Read_Success_Point
43 void *_Old_Data = __cur_data;
45 equals(__RET__, _Old_Data->read())
50 Type *cur_data_ptr = _data.load(memory_order_acquire);
53 @Commit_point_check_define: true
54 @Label: Read_Success_Point
57 res = cur_data_ptr->read();
64 @Commit_point_set: Write_Success_Point
67 __cur_data = new_data;
70 void write(Type *new_data) {
72 Type *prev = _data.load(memory_order_acquire);
73 if (_data.compare_exchange_weak(prev, new_data,
74 memory_order_release, memory_order_release)) {
77 @Commit_point_check_define: __ATOMIC_RET__ == true
78 @Label: Write_Success_Point