summaryrefslogtreecommitdiff
path: root/performance-tests/Synch-Benchmarks/Benchmark.h
blob: 748cfb3c22a3a7023cc8ab387b2358d44e8ef771 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
/* -*- C++ -*- */
// $Id$

/* Defines the class used to dynamically link in the benchmark tests */

#if !defined (ACE_BENCHMARK_H)
#define ACE_BENCHMARK_H

#include "ace/Service_Config.h"
#include "ace/Synch.h"
#include "ace/Service_Record.h"

#if defined (ACE_HAS_THREADS)

extern int buffer;
extern int synch_count;

#if defined (ACE_HAS_PTHREADS) || defined (VXWORKS)

typedef ACE_Atomic_Op<ACE_Thread_Mutex, int> MT_INT;

class Thr_ID
  // TITLE
  //   A simple class that provides a thread-specific value in order
  //   to compensate for POSIX Pthreads.
  // 
  // DESCRIPTION
  //   Pthreads are too lame to have a sensible scalar values for the
  //   thread id (unlike Solaris threads).   Therefore, we have to
  //   emulate this ourselves with this class (gag).
{
public:
  Thr_ID (void);
  int thr_id (void);
  void thr_id (int);

private:
  int thr_id_;
  static MT_INT thread_id_;
};
#endif /* ACE_HAS_PTHREADS || VXWORKS */

class Benchmark : public ACE_Service_Object
  // TITLE
  //   Base class for all the timing tests.
{
public:
  // = Hooks inherited from ACE_Service_Object.
  virtual int svc (void);
  virtual int init (int, char *[]);
  virtual int info (char **, size_t) const;
  virtual int fini (void);
  static void *svc_run (Benchmark *bp);

  int thr_id (void);
  // Returns our thread id;

  // = Set/get flag that controls how the tests are shut down
  // gracefully.
  static void done (sig_atomic_t);
  static sig_atomic_t done (void);

protected:
  static sig_atomic_t done_;
  // Keeps track if we are finished or not.

#if defined (ACE_HAS_PTHREADS) || defined (ACE_HAS_DCETHREADS) || defined (VXWORKS)
  ACE_TSS <Thr_ID> id_;
  // Keeps track of our "virtual" thread id...
#endif /* ACE_HAS_PTHREADS || ACE_HAS_DCETHREADS || VXWORKS */
};
#endif /* ACE_HAS_THREADS */
#endif /* ACE_BENCHMARK_H */