summaryrefslogtreecommitdiff
path: root/examples/Reactor/WFMO_Reactor/test_exceptions.cpp
blob: 075e35a89e53959fc1f35cbaf0110a97a0f0b2db (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
#include "ace/ReactorEx.h"

class Event_Handler : public ACE_Event_Handler
{
public:
  Event_Handler ()
    : event_ (1)
  {
    ACE_DEBUG ((LM_DEBUG, "Event_Handler created\n"));
  }
  ~Event_Handler ()
  {
    ACE_DEBUG ((LM_DEBUG, "Event_Handler destroyed\n"));
  }
  int handle_signal (int signum, siginfo_t * = 0, ucontext_t * = 0)
  {
    char *cause_exception = 0;
    char a = *cause_exception;
    return 0;
  }
  ACE_HANDLE get_handle (void) const
  {
    return this->event_.handle ();
  }
private:
  ACE_Manual_Event event_;
};

class ACE_ReactorEx_Test
{
public:
  static void doit ()
  {
    for (int i = 1; i <= 10; i++)
      {
	ACE_DEBUG ((LM_DEBUG, "Active threads in ReactorEx (before handle_events) = %d\n", 
		    ACE_Service_Config::reactorEx ()->active_threads_));
	ACE_SEH_TRY 
	  {
	    ACE_Service_Config::reactorEx ()->handle_events ();
	  }
	ACE_SEH_EXCEPT (EXCEPTION_EXECUTE_HANDLER)
	  {
	    ACE_DEBUG ((LM_DEBUG, "Exception occurred\n"));
	  }
	ACE_DEBUG ((LM_DEBUG, "Active threads in ReactorEx (after handle_events) = %d\n", 
		    ACE_Service_Config::reactorEx ()->active_threads_));
      }
  }
};

int
main ()
{
  Event_Handler *handler;
  ACE_NEW_RETURN (handler, Event_Handler, -1);
  ACE_Service_Config::reactorEx ()->register_handler (handler);
  ACE_ReactorEx_Test::doit ();
  delete handler;
  return 0;
}