QuickIO  0.2
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
atomic.h
Go to the documentation of this file.
1 
12 #pragma once
13 #include "quickio.h"
14 
24 static inline gboolean atomic_inc_not_zero(guint *to)
25 {
26  __sync_synchronize();
27  guint val = *to;
28 
29  while (TRUE) {
30  guint old;
31 
32  if (G_UNLIKELY(val == 0)) {
33  break;
34  }
35 
36  old = __sync_val_compare_and_swap(to, val, val + 1);
37  if (G_LIKELY(old == val)) {
38  break;
39  }
40 
41  val = old;
42  }
43 
44  return val > 0;
45 }
Every header, definition, and whatnot QuickIO needs to run.