#include <limits.h>#include "gwlib.h"Include dependency graph for counter.c:

Go to the source code of this file.
Data Structures | |
| struct | Counter |
Defines | |
| #define | lock(c) pthread_spin_lock(&c->lock) |
| #define | unlock(c) pthread_spin_unlock(&c->lock) |
Functions | |
| Counter * | counter_create (void) |
| void | counter_destroy (Counter *counter) |
| unsigned long | counter_increase (Counter *counter) |
| unsigned long | counter_increase_with (Counter *counter, unsigned long value) |
| unsigned long | counter_value (Counter *counter) |
| unsigned long | counter_decrease (Counter *counter) |
| unsigned long | counter_set (Counter *counter, unsigned long n) |
|
|
|
|
Definition at line 94 of file counter.c. References Counter::lock, mutex_create, and Counter::n. Referenced by client_thread(), eq_init(), init_bearerbox(), main(), port_add(), smasi_create(), smpp_create(), smsbox_start(), smsc2_start(), smsc_emu_init(), smscconn_create(), smscconn_send(), store_spool_init(), wap_appl_init(), wap_push_ppg_init(), wapbox_start(), wsp_push_client_init(), wsp_session_init(), wtp_initiator_init(), and wtp_resp_init(). 00095 {
00096 Counter *counter;
00097
00098 counter = gw_malloc(sizeof(Counter));
00099 #ifdef HAVE_PTHREAD_SPINLOCK_T
00100 pthread_spin_init(&counter->lock, 0);
00101 #else
00102 counter->lock = mutex_create();
00103 #endif
00104
00105 counter->n = 0;
00106 return counter;
00107 }
|
|
|
Definition at line 155 of file counter.c. References lock, Counter::n, and unlock. Referenced by get_receiver(), handle_split(), port_get_request(), return_reply(), and store_spool_save(). 00156 {
00157 unsigned long ret;
00158
00159 lock(counter);
00160 ret = counter->n;
00161 if (counter->n > 0)
00162 --counter->n;
00163 unlock(counter);
00164 return ret;
00165 }
|
|
|
Definition at line 110 of file counter.c. References Counter::lock, and mutex_destroy(). Referenced by boxc_cleanup(), client_thread(), empty_msg_lists(), eq_shutdown(), handle_split(), main(), port_remove(), smasi_destroy(), smpp_destroy(), smsc2_cleanup(), smsc_emu_shutdown(), smscconn_destroy(), smscconn_send(), store_spool_shutdown(), wap_appl_shutdown(), wap_push_ppg_shutdown(), wsp_push_client_shutdown(), wsp_session_shutdown(), wtp_initiator_shutdown(), and wtp_resp_shutdown(). 00111 {
00112 if (counter == NULL)
00113 return;
00114
00115 #ifdef HAVE_PTHREAD_SPINLOCK_T
00116 pthread_spin_destroy(&counter->lock);
00117 #else
00118 mutex_destroy(counter->lock);
00119 #endif
00120 gw_free(counter);
00121 }
|
Here is the call graph for this function:

|
|
Definition at line 123 of file counter.c. References lock, Counter::n, and unlock. Referenced by bb_smscconn_receive(), bb_smscconn_send_failed(), bb_smscconn_sent(), boxc_create(), check(), client_thread(), dispatch(), dispatch_datagram(), eq_create_event(), handle_submit_sm(), init_machine_create(), msg_to_pdu(), next_wsp_session_id(), open_connection(), open_receiver(), open_transceiver(), open_transmitter(), port_get_request(), push_client_machine_create(), push_machine_create(), push_thread(), remember_receiver(), resp_machine_create(), send_enquire_link(), send_logoff(), send_message(), send_smpp_thread(), send_unbind(), smpp_create(), smpp_emu_writer(), smsbox_thread(), smscconn_send(), start_fetch(), store_spool_save(), udp_receiver(), and udp_sender(). 00124 {
00125 unsigned long ret;
00126
00127 lock(counter);
00128 ret = counter->n;
00129 ++counter->n;
00130 unlock(counter);
00131 return ret;
00132 }
|
|
||||||||||||
|
Definition at line 134 of file counter.c. References lock, Counter::n, and unlock. Referenced by smscconn_send(). 00135 {
00136 unsigned long ret;
00137
00138 lock(counter);
00139 ret = counter->n;
00140 counter->n += value;
00141 unlock(counter);
00142 return ret;
00143 }
|
|
||||||||||||
|
Definition at line 167 of file counter.c. References lock, Counter::n, and unlock. Referenced by smscconn_send(). 00168 {
00169 unsigned long ret;
00170
00171 lock(counter);
00172 ret = counter->n;
00173 counter->n = n;
00174 unlock(counter);
00175 return ret;
00176 }
|
|
|
Definition at line 145 of file counter.c. References lock, Counter::n, and unlock. Referenced by bb_print_status(), empty_msg_lists(), main(), outstanding_requests(), port_remove(), send_smpp_thread(), smscconn_info(), store_spool_load(), store_spool_messages(), and wap_appl_get_load(). 00146 {
00147 unsigned long ret;
00148
00149 lock(counter);
00150 ret = counter->n;
00151 unlock(counter);
00152 return ret;
00153 }
|