Kannel: Open Source WAP and SMS gateway  $Revision: 5037 $
check_counter.c File Reference
#include <limits.h>
#include "gwlib/gwlib.h"

Go to the source code of this file.

Macros

#define THREADS   16
 
#define PER_THREAD   (1000)
 

Functions

static void check (void *arg)
 
int main (void)
 

Macro Definition Documentation

#define PER_THREAD   (1000)

Definition at line 71 of file check_counter.c.

Referenced by check().

#define THREADS   16

Definition at line 67 of file check_counter.c.

Referenced by main().

Function Documentation

static void check ( void *  arg)
static

Definition at line 76 of file check_counter.c.

References counter_increase(), panic, and PER_THREAD.

Referenced by decode_binary_data(), escape_data(), main(), and unescape_data().

76  {
77  Counter *c;
78  long i, this, prev;
79 
80  c = arg;
81  prev = -1;
82  for (i = 0; i < PER_THREAD; ++i) {
83  this = counter_increase(c);
84  if (this < 0)
85  panic(0, "counter returned negative");
86  if (this < prev)
87  panic(0, "counter returned smaller than previous");
88  prev = this;
89  }
90 }
unsigned long counter_increase(Counter *counter)
Definition: counter.c:123
#define PER_THREAD
Definition: check_counter.c:71
#define panic
Definition: log.h:87
int main ( void  )

Definition at line 93 of file check_counter.c.

References check(), counter_create(), GW_INFO, gwlib_init(), gwthread_create, gwthread_join(), log_set_output_level(), THREADS, and threads.

93  {
94  Counter *c;
95  long threads[THREADS];
96  long i;
97 
98  gwlib_init();
100  c = counter_create();
101  for (i = 0; i < THREADS; ++i)
102  threads[i] = gwthread_create(check, c);
103  for (i = 0; i < THREADS; ++i)
104  gwthread_join(threads[i]);
105 
106  return 0;
107 }
int threads
Definition: fakewap.c:239
void gwthread_join(long thread)
static void check(void *arg)
Definition: check_counter.c:76
Counter * counter_create(void)
Definition: counter.c:94
void log_set_output_level(enum output_level level)
Definition: log.c:217
#define gwthread_create(func, arg)
Definition: gwthread.h:90
#define THREADS
Definition: check_counter.c:67
Definition: log.h:69
void gwlib_init(void)
Definition: gwlib.c:78
See file LICENSE for details about the license agreement for using, modifying, copying or deriving work from this software.