summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/tests/Notify/lib/Periodic_Consumer.h
blob: 8858c155029ef7532b02df36be733215301b59c0 (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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
/* -*- C++ -*- */
/**
 *  @file Periodic_Consumer.h
 *
 *  $Id$
 *
 *  @author Pradeep Gore <pradeep@oomworks.com>
 *
 *
 */

#ifndef TAO_Notify_Tests_PERIODIC_CONSUMER_H
#define TAO_Notify_Tests_PERIODIC_CONSUMER_H
#include /**/ "ace/pre.h"

#include "notify_test_export.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#include "Task_Stats.h"
#include "Notify_StructuredPushConsumer.h"

#include "ace/Arg_Shifter.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL
class ACE_Barrier;
//class ACE_TArg_Shifter< char >;
ACE_END_VERSIONED_NAMESPACE_DECL

class TAO_Notify_Tests_Task_Callback;

/**
 * @class TAO_Notify_Tests_Periodic_Consumer
 *
 * @brief Receives Structured events periodically.
 *
 */
class TAO_NOTIFY_TEST_Export TAO_Notify_Tests_Periodic_Consumer : public TAO_Notify_Tests_StructuredPushConsumer
{
public:
  /// Constuctor
  TAO_Notify_Tests_Periodic_Consumer (void);

  /// Destructor
  ~TAO_Notify_Tests_Periodic_Consumer ();

  /// set the helper callback
  void task_callback(TAO_Notify_Tests_Task_Callback* client);

  /// Init the state of this object.
  virtual int init_state (ACE_TArg_Shifter< char >& arg_shifter);

  /// dump stats
  void dump_stats (const ACE_TCHAR* msg, int dump_samples);

protected:

  virtual void push_structured_event (
        const CosNotification::StructuredEvent & notification
        ACE_ENV_ARG_DECL
      )
      ACE_THROW_SPEC ((
        CORBA::SystemException,
        CosEventComm::Disconnected
       ));

  void handle_start_event (const CosNotification::PropertySeq& prop_seq);
  void check_priority (const CosNotification::PropertySeq& prop_seq);

  /// = Data members.
  /// Serialize state.
  TAO_SYNCH_MUTEX lock_;

  /// count of events received.
  int count_;

  /// We need to count down these initial events.
  int warmup_countdown_;

  /// max events expected.
  /// Sometimes max count may not be the number of events that the supplier will send.
  /// A filter might not allow some events to through. we can tell the consumer what to expect.
  int max_count_;

  /// The Load
  CORBA::ULong load_;

  /// Stats house keeping
  Task_Stats stats_;

  /// Client
  TAO_Notify_Tests_Task_Callback* client_;

  /// Flag to indicate if we want to check the expected priority.
  int check_priority_;

  /// This Flag is set if we received an event asking us to "Stop".
  int stop_received_;
};

#include /**/ "ace/post.h"
#endif /* TAO_Notify_Tests_PERIODIC_CONSUMER_H */