zmq_atomic_counter_destroy.txt 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162
  1. zmq_atomic_counter_destroy(3)
  2. =============================
  3. NAME
  4. ----
  5. zmq_atomic_counter_destroy - destroy an atomic counter
  6. SYNOPSIS
  7. --------
  8. *void zmq_atomic_counter_destroy (void **counter_p);*
  9. DESCRIPTION
  10. -----------
  11. The _zmq_atomic_counter_destroy_ function destroys an atomic counter and
  12. nullifies its reference. Pass the address of an atomic counter (void **)
  13. rather than the counter itself. You must destroy all counters that you
  14. create, to avoid memory leakage. This function uses platform specific
  15. atomic operations.
  16. RETURN VALUE
  17. ------------
  18. The _zmq_atomic_counter_destroy()_ function has no return value.
  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_value[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>.