zmq_atomic_counter_value.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. zmq_atomic_counter_value(3)
  2. ===========================
  3. NAME
  4. ----
  5. zmq_atomic_counter_value - return value of atomic counter
  6. SYNOPSIS
  7. --------
  8. *int zmq_atomic_counter_value (void *counter);*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_atomic_counter_value_ function returns the value of an atomic
  12. counter created by _zmq_atomic_counter_new()_. This function uses platform
  13. specific atomic operations.
  14. RETURN VALUE
  15. ------------
  16. The _zmq_atomic_counter_value()_ function returns the value of the
  17. atomic counter. If _counter_ does not point to an atomic counter created by
  18. _zmq_atomic_counter_new()_, the behaviour is undefined.
  19. EXAMPLE
  20. -------
  21. .Test code for atomic counters
  22. ----
  23. void *counter = zmq_atomic_counter_new ();
  24. assert (zmq_atomic_counter_value (counter) == 0);
  25. assert (zmq_atomic_counter_inc (counter) == 0);
  26. assert (zmq_atomic_counter_inc (counter) == 1);
  27. assert (zmq_atomic_counter_inc (counter) == 2);
  28. assert (zmq_atomic_counter_value (counter) == 3);
  29. assert (zmq_atomic_counter_dec (counter) == 1);
  30. assert (zmq_atomic_counter_dec (counter) == 1);
  31. assert (zmq_atomic_counter_dec (counter) == 0);
  32. zmq_atomic_counter_set (counter, 2);
  33. assert (zmq_atomic_counter_dec (counter) == 1);
  34. assert (zmq_atomic_counter_dec (counter) == 0);
  35. zmq_atomic_counter_destroy (&counter);
  36. return 0;
  37. ----
  38. SEE ALSO
  39. --------
  40. linkzmq:zmq_atomic_counter_new[3]
  41. linkzmq:zmq_atomic_counter_set[3]
  42. linkzmq:zmq_atomic_counter_inc[3]
  43. linkzmq:zmq_atomic_counter_dec[3]
  44. linkzmq:zmq_atomic_counter_destroy[3]
  45. AUTHORS
  46. -------
  47. This page was written by the 0MQ community. To make a change please
  48. read the 0MQ Contribution Policy at <http://www.zeromq.org/docs:contributing>.