diff options
author | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-30 06:50:29 +0000 |
---|---|---|
committer | nobody <nobody@ae88bc3d-4319-0410-8dbf-d08b4c9d3795> | 1996-12-30 06:50:29 +0000 |
commit | a4a7690c336d4c8a16b3041c86d501ba38226e96 (patch) | |
tree | 9e9f93a98edd2591453f092d178ad29a1c5fb519 /examples/Reactor/ReactorEx | |
parent | a5c4d8047ab58df5c45092e18ae503ad40518f0e (diff) | |
download | ATCD-unlabeled-4.1.2.tar.gz |
This commit was manufactured by cvs2svn to create branchunlabeled-4.1.2
'unlabeled-4.1.2'.
Diffstat (limited to 'examples/Reactor/ReactorEx')
-rw-r--r-- | examples/Reactor/ReactorEx/README | 224 | ||||
-rw-r--r-- | examples/Reactor/ReactorEx/reactorex.mak | 583 | ||||
-rw-r--r-- | examples/Reactor/ReactorEx/reactorex.mdp | bin | 61952 -> 0 bytes | |||
-rw-r--r-- | examples/Reactor/ReactorEx/test_reactorEx.cpp | 428 | ||||
-rw-r--r-- | examples/Reactor/ReactorEx/test_remove_handler.cpp | 94 | ||||
-rw-r--r-- | examples/Reactor/ReactorEx/test_timeout.cpp | 72 |
6 files changed, 0 insertions, 1401 deletions
diff --git a/examples/Reactor/ReactorEx/README b/examples/Reactor/ReactorEx/README deleted file mode 100644 index 17fa59edf25..00000000000 --- a/examples/Reactor/ReactorEx/README +++ /dev/null @@ -1,224 +0,0 @@ -The ACE_ReactorEx encapsulates the Win32 WaitForMultipleObjects() API -within ACE. The ACE_ReactorEx is similar in spirit to the -ACE_Reactor, except that (1) it is much simpler and (2) it works for -the complete range of Win32 handles (whereas the ACE_Reactor just -works for socket handles. - -Here's the API for the ACE_ReactorEx: - -class ACE_ReactorEx -{ -public: - // = Event loop. - virtual int handle_events (ACE_Time_Value *); - - // = Handler registration management. - virtual int register_handler (ACE_Event_Handler *); - virtual int remove_handler (ACE_Event_Handler *); - - virtual int notify (void); - - // = Timer management - virtual int schedule_timer (), etc. - // ... -}; - ----------------------------------------- - -Here's how you might use it: - ----------------------------------------- - -class My_Thread_Handler : public ACE_Event_Handler -{ -public: - My_Thread_Handler (void) { - // Create a thread that will run - // for a time and then exit. - this->thread_handle_ = - ACE_OS::thr_create (run, ......); - } - - // Called back by the ACE_ReactorEx when the - // event is signaled. - virtual int handle_signal (int) - { - cout << "thread is done" << endl; - } - - virtual ACE_HANDLE get_handle (void) const - { - return this->thread_handle_; - } - -private: - ACE_HANDLE thread_handle_; - - static void *run (void *) { - // Sleep for a while and then exit. - ACE_OS::sleep (100000); - return 0; - } -}; - ----------------------------------------- - -The main program might look something like this: - ----------------------------------------- - -int main (void) -{ - // ... - ACE_ReactorEx dispatcher; - My_Thread_Handler handler; - - // Register the thread handler. - dispatcher.register_handler (&handler); - - // Block until the thread exits and the - // handle_signal() method of the My_Thread_Handler - // is called! - dispatcher.handle_events (); - - // ... -} - ----------------------------------------- - -. test_timeout -- - -This example application shows how to write ReactorEx and Proactor -event loops that handle events for some fixed amount of time. It uses -ACE_Service_Config::run_reactorEx_event_loop (run_time) to handle -events for run_time seconds. The output should be the following: - -1 timeout occurred for Foo. -2 timeout occurred for Bar. -3 timeout occurred for Foo. -4 timeout occurred for Bar. -5 timeout occurred for Foo. -6 timeout occurred for Bar. -7 timeout occurred for Foo. -8 timeout occurred for Foo. -9 timeout occurred for Bar. -10 timeout occurred for Foo. -11 timeout occurred for Bar. -12 timeout occurred for Foo. - -. test_remove_handler -- - -This application tests the ReactorEx's ability to handle simultaneous -events. If you pass anything on the command-line, then each handler -requests to be removed from the ReactorEx after each event. This has -a funky effect on the order in which handlers are serviced. So, if no -parameters are passed in, the handlers should be serviced 1 through -MAXIMUM_WAIT_OBJECTS. If handlers to request to be removed as signals -occur, they will be serviced 1, MAX, MAX-1, ..., 2. This is because -of a ReactorEx bookkeeping optimization. - -. test_reactorEx.cpp -- - -This test application tests a wide range of events that can be -demultiplexed using various ACE utilities. Events used include ^C -events, reading from STDIN, vanilla Win32 events, thread exits, -ReactorEx notifications, proactive reads, and proactive writes. - -The proactive I/O events are demultiplexed by the ACE_Proactor. The -thread exits, notications, and vanilla Win32 events are demultiplexed -by the ACE_ReactorEx. To enable a single thread to run all these -events, the Proactor is integrated with the ReactorEx. - -The test application prototypes a simple ntalk program. Two instances -of the application connect. Input from either console is displayed on -the others console also. Because of the evils of Win32 STDIN, a -separate thread is used to read from STDIN. To test the Proactor and -ReactorEx, I/O between the remote processes is performed proactively -and interactions between the STDIN thread and the main thread are -performed reactively. - -The following description of the test application is in two parts. -The participants section explains the main components involved in the -application. The collaboration section describes how the partipants -interact in response to the multiple event types which occur. - -The ReactorEx test application has the following participants: - -. ReactorEx -- The ReactorEx demultiplexes Win32 "waitable" events - using WaitForMultipleObjects. - -. Proactor -- The proactor initiates and demultiplexes overlapped I/O - operations. The Proactor registers with the ReactorEx so that a - single-thread can demultiplex all application events. - -. STDIN_Handler -- STDIN_Handler is an Active Object which reads from - STDIN and forwards the input to the Peer_Handler. This runs - in a separate thread to make the test more interesting. However, - STDIN is "waitable", so in general it can be waited on by the ACE - ReactorEx, thanks MicroSlush! - -. Peer_Handler -- The Peer_Handler connects to another instance of - test_reactorEx. It Proactively reads and writes data to the peer. - When the STDIN_Handler gives it messages, it fowards them to the - remote peer. When it receives messages from the remote peer, it - prints the output to the console. - -The collaborations of the participants are as follows: - -. Initialization - - Peer_Handler -- connects to the remote peer. It then begins - proactively reading from the remote connection. Note that it will - be notified by the Proactor when a read completes. It also - registers a new_msg_event with the ReactorEx. Note that when the - new_msg_event is signaled (by the STDIN_Handler), - Peer_Handler::handle_signal will get called. - - STDIN_Handler -- STDIN_Handler registers a signal handler for - SIGINT. This just captures the exception so that the kernel doesn't - kill our process; We want to exit gracefully. It also creates an - Exit_Hook object which registers the STDIN_Handler's thread handle - with the ReactorEx. The Exit_Hook will get called back when the - STDIN_Handler thread exits. After registering these, it blocks - reading from STDIN. - - Proactor -- is registered with the ReactorEx. - - The main thread of control waits in the ReactorEx. - -. STDIN events -- When the STDIN_Handler thread reads from STDIN, it - puts the message on Peer_Handler's message queue and signals the - new_msg_event. It then returns to reading from STDIN. - -. new_msg_events -- The ReactorEx thread wakes up and calls - Peer_Handler::handle_signal. The Peer_Handler then tries to dequeue - a message from its message queue. If it can, the message is - Proactively sent to the remote peer. Note that the Peer_Handler - will be notified with this operation is complete. The Peer_Handler - then falls back into the ReactorEx event loop. - -. Send complete event -- When a proactive send is complete, the - Proactor is notified by the ReactorEx. The Proactor, in turn, - notifies the Peer_Handler. The Peer_Handler then checks for more - messages from the message queue. If there are any, it tries to send - them. If there are not, it returns to the ReactorEx event loop. - This is ok since it is notified via new_msg_event when new message - arrive. - -. Read complete event -- When a proactive read is complete (the - Peer_Handler initiated a proactive read when it connected to the - remote peer), the Proactor is notified by the ReactorEx. The - Proactor, in turn notifies the Peer_Handler. If the read was - successful the Peer_Handler just displays the received msg to the - console and reinvokes a proactive read from the network connection. - If the read failed (i.e. the remote peer exited), the Peer_Handler - sets a flag to end the event loop and returns. This will cause the - application to exit. - -. ^C events -- When the user types ^C at the console, the - STDIN_Handler's signal handler will be called. It does nothing, but - as a result of the signal, the STDIN_Handler thread will exit. - -. STDIN_Handler thread exits -- The Exit_Hook will get called back - from the ReactorEx. Exit_Hook::handle_signal sets a flag to end the - event loop and returns. This will cause the application to exit. diff --git a/examples/Reactor/ReactorEx/reactorex.mak b/examples/Reactor/ReactorEx/reactorex.mak deleted file mode 100644 index 7e94098ede0..00000000000 --- a/examples/Reactor/ReactorEx/reactorex.mak +++ /dev/null @@ -1,583 +0,0 @@ -# Microsoft Developer Studio Generated NMAKE File, Format Version 4.20
-# ** DO NOT EDIT **
-
-# TARGTYPE "Win32 (x86) Console Application" 0x0103
-
-!IF "$(CFG)" == ""
-CFG=test_timeout - Win32 Debug
-!MESSAGE No configuration specified. Defaulting to test_timeout - Win32 Debug.
-!ENDIF
-
-!IF "$(CFG)" != "ntalk - Win32 Debug" && "$(CFG)" !=\
- "test_remove_handler - Win32 Debug" && "$(CFG)" != "test_timeout - Win32 Debug"
-!MESSAGE Invalid configuration "$(CFG)" specified.
-!MESSAGE You can specify a configuration when running NMAKE on this makefile
-!MESSAGE by defining the macro CFG on the command line. For example:
-!MESSAGE
-!MESSAGE NMAKE /f "reactorEx.mak" CFG="test_timeout - Win32 Debug"
-!MESSAGE
-!MESSAGE Possible choices for configuration are:
-!MESSAGE
-!MESSAGE "ntalk - Win32 Debug" (based on "Win32 (x86) Console Application")
-!MESSAGE "test_remove_handler - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE "test_timeout - Win32 Debug" (based on\
- "Win32 (x86) Console Application")
-!MESSAGE
-!ERROR An invalid configuration is specified.
-!ENDIF
-
-!IF "$(OS)" == "Windows_NT"
-NULL=
-!ELSE
-NULL=nul
-!ENDIF
-################################################################################
-# Begin Project
-# PROP Target_Last_Scanned "ntalk - Win32 Debug"
-CPP=cl.exe
-RSC=rc.exe
-
-!IF "$(CFG)" == "ntalk - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "ntalk\Debug"
-# PROP BASE Intermediate_Dir "ntalk\Debug"
-# PROP BASE Target_Dir "ntalk"
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "debug"
-# PROP Target_Dir "ntalk"
-OUTDIR=.
-INTDIR=.\debug
-
-ALL : "$(OUTDIR)\test_reactorEx.exe"
-
-CLEAN :
- -@erase "$(INTDIR)\test_reactorEx.obj"
- -@erase "$(INTDIR)\vc40.idb"
- -@erase "$(INTDIR)\vc40.pdb"
- -@erase "$(OUTDIR)\test_reactorEx.exe"
- -@erase "$(OUTDIR)\test_reactorEx.ilk"
- -@erase "$(OUTDIR)\test_reactorEx.pdb"
-
-"$(INTDIR)" :
- if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
-
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-CPP_PROJ=/nologo /MDd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
- /Fp"$(INTDIR)/ntalk.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
-CPP_OBJS=.\debug/
-CPP_SBRS=.\.
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/ntalk.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /debug /machine:I386 /out:"test_reactorEx.exe"
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
- odbccp32.lib ace.lib /nologo /subsystem:console /incremental:yes\
- /pdb:"$(OUTDIR)/test_reactorEx.pdb" /debug /machine:I386\
- /out:"$(OUTDIR)/test_reactorEx.exe"
-LINK32_OBJS= \
- "$(INTDIR)\test_reactorEx.obj"
-
-"$(OUTDIR)\test_reactorEx.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "test_remove_handler - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "test_remove_handler\Debug"
-# PROP BASE Intermediate_Dir "test_remove_handler\Debug"
-# PROP BASE Target_Dir "test_remove_handler"
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir "test_remove_handler"
-OUTDIR=.
-INTDIR=.\Debug
-
-ALL : "$(OUTDIR)\test_remove_handler.exe"
-
-CLEAN :
- -@erase "$(INTDIR)\test_remove_handler.obj"
- -@erase "$(INTDIR)\vc40.idb"
- -@erase "$(INTDIR)\vc40.pdb"
- -@erase "$(OUTDIR)\test_remove_handler.exe"
- -@erase "$(OUTDIR)\test_remove_handler.ilk"
- -@erase "$(OUTDIR)\test_remove_handler.pdb"
-
-"$(INTDIR)" :
- if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
-
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
- /Fp"$(INTDIR)/test_remove_handler.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
-CPP_OBJS=.\Debug/
-CPP_SBRS=.\.
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/test_remove_handler.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /debug /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
- odbccp32.lib ace.lib /nologo /subsystem:console /incremental:yes\
- /pdb:"$(OUTDIR)/test_remove_handler.pdb" /debug /machine:I386\
- /out:"$(OUTDIR)/test_remove_handler.exe"
-LINK32_OBJS= \
- "$(INTDIR)\test_remove_handler.obj"
-
-"$(OUTDIR)\test_remove_handler.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ELSEIF "$(CFG)" == "test_timeout - Win32 Debug"
-
-# PROP BASE Use_MFC 0
-# PROP BASE Use_Debug_Libraries 1
-# PROP BASE Output_Dir "test_timeout\Debug"
-# PROP BASE Intermediate_Dir "test_timeout\Debug"
-# PROP BASE Target_Dir "test_timeout"
-# PROP Use_MFC 0
-# PROP Use_Debug_Libraries 1
-# PROP Output_Dir ""
-# PROP Intermediate_Dir "Debug"
-# PROP Target_Dir "test_timeout"
-OUTDIR=.
-INTDIR=.\Debug
-
-ALL : "$(OUTDIR)\test_timeout.exe"
-
-CLEAN :
- -@erase "$(INTDIR)\test_timeout.obj"
- -@erase "$(INTDIR)\vc40.idb"
- -@erase "$(INTDIR)\vc40.pdb"
- -@erase "$(OUTDIR)\test_timeout.exe"
- -@erase "$(OUTDIR)\test_timeout.ilk"
- -@erase "$(OUTDIR)\test_timeout.pdb"
-
-"$(INTDIR)" :
- if not exist "$(INTDIR)/$(NULL)" mkdir "$(INTDIR)"
-
-# ADD BASE CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-# ADD CPP /nologo /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /YX /c
-CPP_PROJ=/nologo /MLd /W3 /Gm /GX /Zi /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE"\
- /Fp"$(INTDIR)/test_timeout.pch" /YX /Fo"$(INTDIR)/" /Fd"$(INTDIR)/" /c
-CPP_OBJS=.\Debug/
-CPP_SBRS=.\.
-# ADD BASE RSC /l 0x409 /d "_DEBUG"
-# ADD RSC /l 0x409 /d "_DEBUG"
-BSC32=bscmake.exe
-# ADD BASE BSC32 /nologo
-# ADD BSC32 /nologo
-BSC32_FLAGS=/nologo /o"$(OUTDIR)/test_timeout.bsc"
-BSC32_SBRS= \
-
-LINK32=link.exe
-# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386
-# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib ace.lib /nologo /subsystem:console /debug /machine:I386
-LINK32_FLAGS=kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib\
- advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib\
- odbccp32.lib ace.lib /nologo /subsystem:console /incremental:yes\
- /pdb:"$(OUTDIR)/test_timeout.pdb" /debug /machine:I386\
- /out:"$(OUTDIR)/test_timeout.exe"
-LINK32_OBJS= \
- "$(INTDIR)\test_timeout.obj"
-
-"$(OUTDIR)\test_timeout.exe" : "$(OUTDIR)" $(DEF_FILE) $(LINK32_OBJS)
- $(LINK32) @<<
- $(LINK32_FLAGS) $(LINK32_OBJS)
-<<
-
-!ENDIF
-
-.c{$(CPP_OBJS)}.obj:
- $(CPP) $(CPP_PROJ) $<
-
-.cpp{$(CPP_OBJS)}.obj:
- $(CPP) $(CPP_PROJ) $<
-
-.cxx{$(CPP_OBJS)}.obj:
- $(CPP) $(CPP_PROJ) $<
-
-.c{$(CPP_SBRS)}.sbr:
- $(CPP) $(CPP_PROJ) $<
-
-.cpp{$(CPP_SBRS)}.sbr:
- $(CPP) $(CPP_PROJ) $<
-
-.cxx{$(CPP_SBRS)}.sbr:
- $(CPP) $(CPP_PROJ) $<
-
-################################################################################
-# Begin Target
-
-# Name "ntalk - Win32 Debug"
-################################################################################
-# Begin Source File
-
-SOURCE=.\test_reactorEx.cpp
-DEP_CPP_TEST_=\
- {$(INCLUDE)}"\ace\ACE.h"\
- {$(INCLUDE)}"\ace\ACE.i"\
- {$(INCLUDE)}"\ace\Addr.h"\
- {$(INCLUDE)}"\ace\Addr.i"\
- {$(INCLUDE)}"\ace\config.h"\
- {$(INCLUDE)}"\ace\Event_Handler.h"\
- {$(INCLUDE)}"\ace\Event_Handler.i"\
- {$(INCLUDE)}"\ace\Get_Opt.h"\
- {$(INCLUDE)}"\ace\Get_Opt.i"\
- {$(INCLUDE)}"\ace\Handle_Set.h"\
- {$(INCLUDE)}"\ace\Handle_Set.i"\
- {$(INCLUDE)}"\ace\INET_Addr.h"\
- {$(INCLUDE)}"\ace\INET_Addr.i"\
- {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
- {$(INCLUDE)}"\ace\IPC_SAP.h"\
- {$(INCLUDE)}"\ace\IPC_SAP.i"\
- {$(INCLUDE)}"\ace\Local_Tokens.h"\
- {$(INCLUDE)}"\ace\Local_Tokens.i"\
- {$(INCLUDE)}"\ace\Log_Msg.h"\
- {$(INCLUDE)}"\ace\Log_Priority.h"\
- {$(INCLUDE)}"\ace\log_record.h"\
- {$(INCLUDE)}"\ace\Log_Record.i"\
- {$(INCLUDE)}"\ace\Malloc.h"\
- {$(INCLUDE)}"\ace\Malloc.i"\
- {$(INCLUDE)}"\ace\Malloc_T.cpp"\
- {$(INCLUDE)}"\ace\Malloc_T.h"\
- {$(INCLUDE)}"\ace\Malloc_T.i"\
- {$(INCLUDE)}"\ace\Map_Manager.cpp"\
- {$(INCLUDE)}"\ace\Map_Manager.h"\
- {$(INCLUDE)}"\ace\Map_Manager.i"\
- {$(INCLUDE)}"\ace\Mem_Map.h"\
- {$(INCLUDE)}"\ace\Mem_Map.i"\
- {$(INCLUDE)}"\ace\Memory_Pool.h"\
- {$(INCLUDE)}"\ace\Memory_Pool.i"\
- {$(INCLUDE)}"\ace\Message_Block.h"\
- {$(INCLUDE)}"\ace\Message_Block.i"\
- {$(INCLUDE)}"\ace\Message_Queue.cpp"\
- {$(INCLUDE)}"\ace\Message_Queue.h"\
- {$(INCLUDE)}"\ace\Message_Queue.i"\
- {$(INCLUDE)}"\ace\Module.cpp"\
- {$(INCLUDE)}"\ace\Module.h"\
- {$(INCLUDE)}"\ace\Module.i"\
- {$(INCLUDE)}"\ace\OS.h"\
- {$(INCLUDE)}"\ace\OS.i"\
- {$(INCLUDE)}"\ace\Pipe.h"\
- {$(INCLUDE)}"\ace\Pipe.i"\
- {$(INCLUDE)}"\ace\Proactor.h"\
- {$(INCLUDE)}"\ace\Proactor.i"\
- {$(INCLUDE)}"\ace\Reactor.h"\
- {$(INCLUDE)}"\ace\Reactor.i"\
- {$(INCLUDE)}"\ace\ReactorEx.h"\
- {$(INCLUDE)}"\ace\ReactorEx.i"\
- {$(INCLUDE)}"\ace\Service_Config.h"\
- {$(INCLUDE)}"\ace\Service_Config.i"\
- {$(INCLUDE)}"\ace\Service_Object.h"\
- {$(INCLUDE)}"\ace\Service_Object.i"\
- {$(INCLUDE)}"\ace\Set.cpp"\
- {$(INCLUDE)}"\ace\Set.h"\
- {$(INCLUDE)}"\ace\Set.i"\
- {$(INCLUDE)}"\ace\Shared_Object.h"\
- {$(INCLUDE)}"\ace\Shared_Object.i"\
- {$(INCLUDE)}"\ace\Signal.h"\
- {$(INCLUDE)}"\ace\Signal.i"\
- {$(INCLUDE)}"\ace\SOCK.h"\
- {$(INCLUDE)}"\ace\SOCK.i"\
- {$(INCLUDE)}"\ace\SOCK_Acceptor.h"\
- {$(INCLUDE)}"\ace\SOCK_Acceptor.i"\
- {$(INCLUDE)}"\ace\SOCK_Connector.h"\
- {$(INCLUDE)}"\ace\SOCK_Connector.i"\
- {$(INCLUDE)}"\ace\SOCK_IO.h"\
- {$(INCLUDE)}"\ace\SOCK_IO.i"\
- {$(INCLUDE)}"\ace\SOCK_Stream.h"\
- {$(INCLUDE)}"\ace\SOCK_Stream.i"\
- {$(INCLUDE)}"\ace\Stack.cpp"\
- {$(INCLUDE)}"\ace\Stack.h"\
- {$(INCLUDE)}"\ace\Stack.i"\
- {$(INCLUDE)}"\ace\stdcpp.h"\
- {$(INCLUDE)}"\ace\Strategies.h"\
- {$(INCLUDE)}"\ace\Strategies_T.cpp"\
- {$(INCLUDE)}"\ace\Strategies_T.h"\
- {$(INCLUDE)}"\ace\Stream_Modules.cpp"\
- {$(INCLUDE)}"\ace\Stream_Modules.h"\
- {$(INCLUDE)}"\ace\Stream_Modules.i"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
- {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
- {$(INCLUDE)}"\ace\Synch.h"\
- {$(INCLUDE)}"\ace\Synch.i"\
- {$(INCLUDE)}"\ace\Synch_Options.h"\
- {$(INCLUDE)}"\ace\Synch_T.cpp"\
- {$(INCLUDE)}"\ace\Synch_T.h"\
- {$(INCLUDE)}"\ace\Synch_T.i"\
- {$(INCLUDE)}"\ace\Task.h"\
- {$(INCLUDE)}"\ace\Task.i"\
- {$(INCLUDE)}"\ace\Task_T.cpp"\
- {$(INCLUDE)}"\ace\Task_T.h"\
- {$(INCLUDE)}"\ace\Task_T.i"\
- {$(INCLUDE)}"\ace\Thread.h"\
- {$(INCLUDE)}"\ace\Thread.i"\
- {$(INCLUDE)}"\ace\Thread_Manager.h"\
- {$(INCLUDE)}"\ace\Thread_Manager.i"\
- {$(INCLUDE)}"\ace\Time_Value.h"\
- {$(INCLUDE)}"\ace\Time_Value.i"\
- {$(INCLUDE)}"\ace\Timer_Queue.h"\
- {$(INCLUDE)}"\ace\Timer_Queue.i"\
- {$(INCLUDE)}"\ace\Token.h"\
- {$(INCLUDE)}"\ace\Token.i"\
- {$(INCLUDE)}"\ace\Trace.h"\
- {$(INCLUDE)}"\ace\ws2tcpip.h"\
-
-
-"$(INTDIR)\test_reactorEx.obj" : $(SOURCE) $(DEP_CPP_TEST_) "$(INTDIR)"
-
-
-# End Source File
-# End Target
-################################################################################
-# Begin Target
-
-# Name "test_remove_handler - Win32 Debug"
-################################################################################
-# Begin Source File
-
-SOURCE=.\test_remove_handler.cpp
-DEP_CPP_TEST_R=\
- {$(INCLUDE)}"\ace\ACE.h"\
- {$(INCLUDE)}"\ace\ACE.i"\
- {$(INCLUDE)}"\ace\Addr.h"\
- {$(INCLUDE)}"\ace\Addr.i"\
- {$(INCLUDE)}"\ace\config.h"\
- {$(INCLUDE)}"\ace\Event_Handler.h"\
- {$(INCLUDE)}"\ace\Event_Handler.i"\
- {$(INCLUDE)}"\ace\Handle_Set.h"\
- {$(INCLUDE)}"\ace\Handle_Set.i"\
- {$(INCLUDE)}"\ace\INET_Addr.h"\
- {$(INCLUDE)}"\ace\INET_Addr.i"\
- {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
- {$(INCLUDE)}"\ace\IPC_SAP.h"\
- {$(INCLUDE)}"\ace\IPC_SAP.i"\
- {$(INCLUDE)}"\ace\Local_Tokens.h"\
- {$(INCLUDE)}"\ace\Local_Tokens.i"\
- {$(INCLUDE)}"\ace\Log_Msg.h"\
- {$(INCLUDE)}"\ace\Log_Priority.h"\
- {$(INCLUDE)}"\ace\log_record.h"\
- {$(INCLUDE)}"\ace\Log_Record.i"\
- {$(INCLUDE)}"\ace\Malloc.h"\
- {$(INCLUDE)}"\ace\Malloc.i"\
- {$(INCLUDE)}"\ace\Malloc_T.cpp"\
- {$(INCLUDE)}"\ace\Malloc_T.h"\
- {$(INCLUDE)}"\ace\Malloc_T.i"\
- {$(INCLUDE)}"\ace\Map_Manager.cpp"\
- {$(INCLUDE)}"\ace\Map_Manager.h"\
- {$(INCLUDE)}"\ace\Map_Manager.i"\
- {$(INCLUDE)}"\ace\Mem_Map.h"\
- {$(INCLUDE)}"\ace\Mem_Map.i"\
- {$(INCLUDE)}"\ace\Memory_Pool.h"\
- {$(INCLUDE)}"\ace\Memory_Pool.i"\
- {$(INCLUDE)}"\ace\Message_Block.h"\
- {$(INCLUDE)}"\ace\Message_Block.i"\
- {$(INCLUDE)}"\ace\Message_Queue.cpp"\
- {$(INCLUDE)}"\ace\Message_Queue.h"\
- {$(INCLUDE)}"\ace\Message_Queue.i"\
- {$(INCLUDE)}"\ace\OS.h"\
- {$(INCLUDE)}"\ace\OS.i"\
- {$(INCLUDE)}"\ace\Pipe.h"\
- {$(INCLUDE)}"\ace\Pipe.i"\
- {$(INCLUDE)}"\ace\Proactor.h"\
- {$(INCLUDE)}"\ace\Proactor.i"\
- {$(INCLUDE)}"\ace\Reactor.h"\
- {$(INCLUDE)}"\ace\Reactor.i"\
- {$(INCLUDE)}"\ace\ReactorEx.h"\
- {$(INCLUDE)}"\ace\ReactorEx.i"\
- {$(INCLUDE)}"\ace\Service_Config.h"\
- {$(INCLUDE)}"\ace\Service_Config.i"\
- {$(INCLUDE)}"\ace\Service_Object.h"\
- {$(INCLUDE)}"\ace\Service_Object.i"\
- {$(INCLUDE)}"\ace\Set.cpp"\
- {$(INCLUDE)}"\ace\Set.h"\
- {$(INCLUDE)}"\ace\Set.i"\
- {$(INCLUDE)}"\ace\Shared_Object.h"\
- {$(INCLUDE)}"\ace\Shared_Object.i"\
- {$(INCLUDE)}"\ace\Signal.h"\
- {$(INCLUDE)}"\ace\Signal.i"\
- {$(INCLUDE)}"\ace\SOCK.h"\
- {$(INCLUDE)}"\ace\SOCK.i"\
- {$(INCLUDE)}"\ace\SOCK_IO.h"\
- {$(INCLUDE)}"\ace\SOCK_IO.i"\
- {$(INCLUDE)}"\ace\SOCK_Stream.h"\
- {$(INCLUDE)}"\ace\SOCK_Stream.i"\
- {$(INCLUDE)}"\ace\Stack.cpp"\
- {$(INCLUDE)}"\ace\Stack.h"\
- {$(INCLUDE)}"\ace\Stack.i"\
- {$(INCLUDE)}"\ace\stdcpp.h"\
- {$(INCLUDE)}"\ace\Strategies.h"\
- {$(INCLUDE)}"\ace\Strategies_T.cpp"\
- {$(INCLUDE)}"\ace\Strategies_T.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
- {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
- {$(INCLUDE)}"\ace\Synch.h"\
- {$(INCLUDE)}"\ace\Synch.i"\
- {$(INCLUDE)}"\ace\Synch_Options.h"\
- {$(INCLUDE)}"\ace\Synch_T.cpp"\
- {$(INCLUDE)}"\ace\Synch_T.h"\
- {$(INCLUDE)}"\ace\Synch_T.i"\
- {$(INCLUDE)}"\ace\Thread.h"\
- {$(INCLUDE)}"\ace\Thread.i"\
- {$(INCLUDE)}"\ace\Thread_Manager.h"\
- {$(INCLUDE)}"\ace\Thread_Manager.i"\
- {$(INCLUDE)}"\ace\Time_Value.h"\
- {$(INCLUDE)}"\ace\Time_Value.i"\
- {$(INCLUDE)}"\ace\Timer_Queue.h"\
- {$(INCLUDE)}"\ace\Timer_Queue.i"\
- {$(INCLUDE)}"\ace\Token.h"\
- {$(INCLUDE)}"\ace\Token.i"\
- {$(INCLUDE)}"\ace\Trace.h"\
- {$(INCLUDE)}"\ace\ws2tcpip.h"\
-
-
-"$(INTDIR)\test_remove_handler.obj" : $(SOURCE) $(DEP_CPP_TEST_R) "$(INTDIR)"
-
-
-# End Source File
-# End Target
-################################################################################
-# Begin Target
-
-# Name "test_timeout - Win32 Debug"
-################################################################################
-# Begin Source File
-
-SOURCE=.\test_timeout.cpp
-DEP_CPP_TEST_T=\
- {$(INCLUDE)}"\ace\ACE.h"\
- {$(INCLUDE)}"\ace\ACE.i"\
- {$(INCLUDE)}"\ace\Addr.h"\
- {$(INCLUDE)}"\ace\Addr.i"\
- {$(INCLUDE)}"\ace\config.h"\
- {$(INCLUDE)}"\ace\Event_Handler.h"\
- {$(INCLUDE)}"\ace\Event_Handler.i"\
- {$(INCLUDE)}"\ace\Handle_Set.h"\
- {$(INCLUDE)}"\ace\Handle_Set.i"\
- {$(INCLUDE)}"\ace\INET_Addr.h"\
- {$(INCLUDE)}"\ace\INET_Addr.i"\
- {$(INCLUDE)}"\ace\IO_Cntl_Msg.h"\
- {$(INCLUDE)}"\ace\IPC_SAP.h"\
- {$(INCLUDE)}"\ace\IPC_SAP.i"\
- {$(INCLUDE)}"\ace\Local_Tokens.h"\
- {$(INCLUDE)}"\ace\Local_Tokens.i"\
- {$(INCLUDE)}"\ace\Log_Msg.h"\
- {$(INCLUDE)}"\ace\Log_Priority.h"\
- {$(INCLUDE)}"\ace\log_record.h"\
- {$(INCLUDE)}"\ace\Log_Record.i"\
- {$(INCLUDE)}"\ace\Malloc.h"\
- {$(INCLUDE)}"\ace\Malloc.i"\
- {$(INCLUDE)}"\ace\Malloc_T.cpp"\
- {$(INCLUDE)}"\ace\Malloc_T.h"\
- {$(INCLUDE)}"\ace\Malloc_T.i"\
- {$(INCLUDE)}"\ace\Map_Manager.cpp"\
- {$(INCLUDE)}"\ace\Map_Manager.h"\
- {$(INCLUDE)}"\ace\Map_Manager.i"\
- {$(INCLUDE)}"\ace\Mem_Map.h"\
- {$(INCLUDE)}"\ace\Mem_Map.i"\
- {$(INCLUDE)}"\ace\Memory_Pool.h"\
- {$(INCLUDE)}"\ace\Memory_Pool.i"\
- {$(INCLUDE)}"\ace\Message_Block.h"\
- {$(INCLUDE)}"\ace\Message_Block.i"\
- {$(INCLUDE)}"\ace\Message_Queue.cpp"\
- {$(INCLUDE)}"\ace\Message_Queue.h"\
- {$(INCLUDE)}"\ace\Message_Queue.i"\
- {$(INCLUDE)}"\ace\OS.h"\
- {$(INCLUDE)}"\ace\OS.i"\
- {$(INCLUDE)}"\ace\Pipe.h"\
- {$(INCLUDE)}"\ace\Pipe.i"\
- {$(INCLUDE)}"\ace\Proactor.h"\
- {$(INCLUDE)}"\ace\Proactor.i"\
- {$(INCLUDE)}"\ace\Reactor.h"\
- {$(INCLUDE)}"\ace\Reactor.i"\
- {$(INCLUDE)}"\ace\ReactorEx.h"\
- {$(INCLUDE)}"\ace\ReactorEx.i"\
- {$(INCLUDE)}"\ace\Service_Config.h"\
- {$(INCLUDE)}"\ace\Service_Config.i"\
- {$(INCLUDE)}"\ace\Service_Object.h"\
- {$(INCLUDE)}"\ace\Service_Object.i"\
- {$(INCLUDE)}"\ace\Set.cpp"\
- {$(INCLUDE)}"\ace\Set.h"\
- {$(INCLUDE)}"\ace\Set.i"\
- {$(INCLUDE)}"\ace\Shared_Object.h"\
- {$(INCLUDE)}"\ace\Shared_Object.i"\
- {$(INCLUDE)}"\ace\Signal.h"\
- {$(INCLUDE)}"\ace\Signal.i"\
- {$(INCLUDE)}"\ace\SOCK.h"\
- {$(INCLUDE)}"\ace\SOCK.i"\
- {$(INCLUDE)}"\ace\SOCK_IO.h"\
- {$(INCLUDE)}"\ace\SOCK_IO.i"\
- {$(INCLUDE)}"\ace\SOCK_Stream.h"\
- {$(INCLUDE)}"\ace\SOCK_Stream.i"\
- {$(INCLUDE)}"\ace\Stack.cpp"\
- {$(INCLUDE)}"\ace\Stack.h"\
- {$(INCLUDE)}"\ace\Stack.i"\
- {$(INCLUDE)}"\ace\stdcpp.h"\
- {$(INCLUDE)}"\ace\Strategies.h"\
- {$(INCLUDE)}"\ace\Strategies_T.cpp"\
- {$(INCLUDE)}"\ace\Strategies_T.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Complex.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Complex.i"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Simple.h"\
- {$(INCLUDE)}"\ace\SV_Semaphore_Simple.i"\
- {$(INCLUDE)}"\ace\Svc_Conf_Tokens.h"\
- {$(INCLUDE)}"\ace\Synch.h"\
- {$(INCLUDE)}"\ace\Synch.i"\
- {$(INCLUDE)}"\ace\Synch_Options.h"\
- {$(INCLUDE)}"\ace\Synch_T.cpp"\
- {$(INCLUDE)}"\ace\Synch_T.h"\
- {$(INCLUDE)}"\ace\Synch_T.i"\
- {$(INCLUDE)}"\ace\Thread.h"\
- {$(INCLUDE)}"\ace\Thread.i"\
- {$(INCLUDE)}"\ace\Thread_Manager.h"\
- {$(INCLUDE)}"\ace\Thread_Manager.i"\
- {$(INCLUDE)}"\ace\Time_Value.h"\
- {$(INCLUDE)}"\ace\Time_Value.i"\
- {$(INCLUDE)}"\ace\Timer_Queue.h"\
- {$(INCLUDE)}"\ace\Timer_Queue.i"\
- {$(INCLUDE)}"\ace\Token.h"\
- {$(INCLUDE)}"\ace\Token.i"\
- {$(INCLUDE)}"\ace\Trace.h"\
- {$(INCLUDE)}"\ace\ws2tcpip.h"\
-
-
-"$(INTDIR)\test_timeout.obj" : $(SOURCE) $(DEP_CPP_TEST_T) "$(INTDIR)"
-
-
-# End Source File
-# End Target
-# End Project
-################################################################################
diff --git a/examples/Reactor/ReactorEx/reactorex.mdp b/examples/Reactor/ReactorEx/reactorex.mdp Binary files differdeleted file mode 100644 index a0f431530be..00000000000 --- a/examples/Reactor/ReactorEx/reactorex.mdp +++ /dev/null diff --git a/examples/Reactor/ReactorEx/test_reactorEx.cpp b/examples/Reactor/ReactorEx/test_reactorEx.cpp deleted file mode 100644 index 295b36ffda0..00000000000 --- a/examples/Reactor/ReactorEx/test_reactorEx.cpp +++ /dev/null @@ -1,428 +0,0 @@ -// $Id$ - -// ============================================================================ -// -// = LIBRARY -// examples -// -// = FILENAME -// test_reactorEx.cpp -// -// = DESCRIPTION -// This test application tests a wide range of events that can be -// demultiplexed using various ACE utilities. Events used include ^C -// events, reading from STDIN, vanilla Win32 events, thread exits, -// ReactorEx notifications, proactive reads, and proactive writes. -// -// The proactive I/O events are demultiplexed by the ACE_Proactor. -// The thread exits, notications, and vanilla Win32 events are -// demultiplexed by the ACE_ReactorEx. To enable a single thread -// to run all these events, the Proactor is integrated with the -// ReactorEx. -// -// = AUTHOR -// Tim Harrison -// -// ============================================================================ - -#include "ace/ReactorEx.h" -#include "ace/Proactor.h" -#include "ace/SOCK_Connector.h" -#include "ace/SOCK_Acceptor.h" -#include "ace/Get_Opt.h" -#include "ace/Time_Value.h" -#include "ace/Service_Config.h" -#include "ace/Synch.h" -#include "ace/Task.h" - -typedef ACE_Task<ACE_MT_SYNCH> MT_TASK; - -class Peer_Handler : public MT_TASK - // = TITLE - // Connect to a server. Receive messages from STDIN_Handler - // and forward them to the server using proactive I/O. -{ -public: - // = Initialization methods. - Peer_Handler (int argc, char *argv[]); - ~Peer_Handler (void); - - int open (void * =0); - // This method creates the network connection to the remote peer. - // It does blocking connects and accepts depending on whether a - // hostname was specified from the command line. - - virtual int handle_output_complete (ACE_Message_Block *msg, - long bytes_transferred); - // One of our asynchronous writes to the remote peer has completed. - // Make sure it succeeded and then delete the message. - - virtual int handle_input_complete (ACE_Message_Block *msg, - long bytes_transferred); - // The remote peer has sent us something. If it succeeded, print - // out the message and reinitiate a read. Otherwise, fail. In both - // cases, delete the message sent. - - virtual ACE_Message_Block *get_message (void); - // This is so the Proactor can get a message to read into. - - virtual ACE_HANDLE get_handle (void) const; - // This is so the Proactor can get our handle. - - virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask); - // We've been removed from the ReactorEx. - - virtual int handle_output (ACE_HANDLE fd); - // Called when output events should start. Note that this is - // automatically invoked by the - // <ACE_ReactorEx_Notificiation_Strategy>. - -private: - ACE_SOCK_Stream stream_; - // Socket that we have connected to the server. - - ACE_ReactorEx_Notification_Strategy strategy_; - // The strategy object that the reactorEx uses to notify us when - // something is added to the queue. - - // = Remote peer info. - char *host_; - // Name of remote host. - - u_short port_; - // Port number for remote host. -}; - -class STDIN_Handler : public ACE_Task<ACE_NULL_SYNCH> - // = TITLE - // Active Object. Reads from STDIN and passes message blocks to - // the peer handler. -{ -public: - STDIN_Handler (MT_TASK &ph); - // Initialization. - - virtual int open (void * = 0); - // Activate object. - - virtual int close (u_long = 0); - // Shut down. - - int svc (void); - // Thread runs here as an active object. - -private: - static void handler (int signum); - // Handle a ^C. (Do nothing, this just illustrates how we can catch - // signals along with the other things). - - void register_thread_exit_hook (void); - // Helper function to register with the ReactorEx for thread exit. - - virtual int handle_signal (int index, siginfo_t *, ucontext_t *); - // The STDIN thread has exited. This means the user hit ^C. We can - // end the event loop. - - MT_TASK &ph_; - // Send all input to ph_. - - ACE_HANDLE thr_handle_; - // Handle of our thread. -}; - -Peer_Handler::Peer_Handler (int argc, char *argv[]) - : host_ (0), - port_ (ACE_DEFAULT_SERVER_PORT), - strategy_ (ACE_Service_Config::reactorEx (), - this, - ACE_Event_Handler::WRITE_MASK) -{ - // This code sets up the message to notify us when a new message is - // added to the queue. Actually, the queue notifies ReactorEx which - // then notifies us. - this->msg_queue ()->notification_strategy (&this->strategy_); - - ACE_Get_Opt get_opt (argc, argv, "h:p:"); - int c; - - while ((c = get_opt ()) != EOF) - { - switch (c) - { - case 'h': - host_ = get_opt.optarg; - break; - case 'p': - port_ = ACE_OS::atoi (get_opt.optarg); - break; - } - } -} - -Peer_Handler::~Peer_Handler (void) -{ -} - -// This method creates the network connection to the remote peer. It -// does blocking connects and accepts depending on whether a hostname -// was specified from the command line. - -int -Peer_Handler::open (void *) -{ - if (host_ != 0) // Connector - { - ACE_INET_Addr addr (port_, host_); - ACE_SOCK_Connector connector; - - // Establish connection with server. - if (connector.connect (stream_, addr) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "connect"), -1); - - ACE_DEBUG ((LM_DEBUG, "connected.\n")); - } - else // Acceptor - { - ACE_SOCK_Acceptor acceptor; - ACE_INET_Addr local_addr (port_); - - if ((acceptor.open (local_addr) == -1) || - (acceptor.accept (this->stream_) == -1)) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "accept failed"), -1); - - ACE_DEBUG ((LM_DEBUG, "accepted.\n")); - } - - return ACE_Service_Config::proactor ()->initiate - (this, ACE_Event_Handler::READ_MASK); -} - -// One of our asynchronous writes to the remote peer has completed. -// Make sure it succeeded and then delete the message. - -int -Peer_Handler::handle_output_complete (ACE_Message_Block *msg, - long bytes_transferred) -{ - if (bytes_transferred <= 0) - ACE_DEBUG ((LM_DEBUG, "%p bytes = %d\n", "Message failed", - bytes_transferred)); - - // This was allocated by the STDIN_Handler, queued, dequeued, - // passed to the proactor, and now passed back to us. - delete msg; - return 0; // Do not reinvoke a send. -} - -// The remote peer has sent us something. If it succeeded, print -// out the message and reinitiate a read. Otherwise, fail. In both -// cases, delete the message sent. - -int -Peer_Handler::handle_input_complete (ACE_Message_Block *msg, - long bytes_transferred) -{ - if (bytes_transferred > 0 && msg->length () > 0) - { - msg->rd_ptr ()[bytes_transferred] = '\0'; - // Print out the message received from the server. - ACE_DEBUG ((LM_DEBUG, "%s", msg->rd_ptr ())); - delete msg; - return 1; // Reinvokes the recv() operation! - } - - delete msg; - // If a read failed, we will assume it's because the remote peer - // went away. We will end the event loop. Since we're in the main - // thread, we don't need to do a notify. - ACE_Service_Config::end_reactorEx_event_loop (); - return -1; // Close down. -} - -// This is so the Proactor can get a message to read into. - -ACE_Message_Block * -Peer_Handler::get_message (void) -{ - // An extra byte for NUL termination. - ACE_Message_Block *message = - new ACE_Message_Block (BUFSIZ + 1); - - message->size (BUFSIZ); - return message; -} - -// This is so the Proactor can get our handle. -ACE_HANDLE -Peer_Handler::get_handle (void) const -{ - return this->stream_.get_handle (); -} - -// We've been removed from the ReactorEx. -int -Peer_Handler::handle_close (ACE_HANDLE, ACE_Reactor_Mask) -{ - ACE_DEBUG ((LM_DEBUG, "Peer_Handler closing down\n")); - return 0; -} - -// New stuff added to the message queue. Try to dequeue a message. -int -Peer_Handler::handle_output (ACE_HANDLE fd) -{ - ACE_Message_Block *mb; - - ACE_Time_Value tv (ACE_Time_Value::zero); - - // Forward the message to the remote peer receiver. - if (this->getq (mb, &tv) != -1) - { - if (ACE_Service_Config::proactor ()-> - initiate (this, ACE_Event_Handler::WRITE_MASK, mb) == -1) - ACE_ERROR ((LM_ERROR, "%p Write initiate.\n", "Peer_Handler")); - } - return 0; -} - -void -STDIN_Handler::handler (int signum) -{ - ACE_DEBUG ((LM_DEBUG, "signal = %S\n", signum)); -} - -STDIN_Handler::STDIN_Handler (MT_TASK &ph) - : ph_ (ph) -{ - // Register for ^C from the console. We just need to catch the - // exception so that the kernel doesn't kill our process. - // Registering this signal handler just tells the kernel that we - // know what we're doing; to leave us alone. - - ACE_OS::signal (SIGINT, ACE_SignalHandler (STDIN_Handler::handler)); -}; - -// Activate object. - -int -STDIN_Handler::open (void *) -{ - if (this->activate (THR_NEW_LWP | THR_DETACHED) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p\n", "spawn"), -1); - - return 0; -} - -// Shut down. - -int -STDIN_Handler::close (u_long) -{ - ACE_DEBUG ((LM_DEBUG, "(%t) thread is exiting.\n")); - return 0; -} - -// Thread runs here. - -int -STDIN_Handler::svc (void) -{ - this->register_thread_exit_hook (); - - for (;;) - { - ACE_Message_Block *mb = new ACE_Message_Block (BUFSIZ); - - // Read from stdin into mb. - int read_result = ACE_OS::read (ACE_STDIN, - mb->rd_ptr (), - mb->size ()); - - // If read succeeds, put mb to peer handler, else end the loop. - if (read_result > 0) - { - mb->wr_ptr (read_result); - // Note that this call will first enqueue mb onto the peer - // handler's message queue, which will then turn around and - // notify the ReactorEx via the Notification_Strategy. This - // will subsequently signal the Peer_Handler, which will - // react by calling back to its handle_output() method, - // which dequeues the message and sends it to the peer - // across the network. - this->ph_.putq (mb); - } - else - break; - } - - // handle_signal will get called on the main proactor thread since - // we just exited and the main thread is waiting on our thread exit. - return 0; -} - -// Register an exit hook with the reactorEx. - -void -STDIN_Handler::register_thread_exit_hook (void) -{ - ACE_hthread_t handle; - - // Get a real handle to our thread. - ACE_Service_Config::thr_mgr ()->thr_self (handle); - - // Register ourselves to get called back when our thread exits. - - if (ACE_Service_Config::reactorEx ()-> - register_handler (this, handle) == -1) - ACE_ERROR ((LM_ERROR, "Exit_Hook Register failed.\n")); - - // We're in another thread, so we need to notify the ReactorEx so - // that it wakes up and waits on the new set of handles. - ACE_Service_Config::reactorEx ()->notify (); -} - -// The STDIN thread has exited. This means the user hit ^C. We can -// end the event loop and delete ourself. - -int -STDIN_Handler::handle_signal (int, siginfo_t *si, ucontext_t *) -{ - ACE_DEBUG ((LM_DEBUG, "STDIN thread has exited.\n")); - ACE_ASSERT (this->thr_handle_ == si->si_handle_); - ACE_Service_Config::end_reactorEx_event_loop (); - return 0; -} - -int -main (int argc, char *argv[]) -{ - // Open handler for remote peer communications this will run from - // the main thread. - Peer_Handler peer_handler (argc, argv); - - if (peer_handler.open () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p open failed, errno = %d.\n", - "peer_handler", errno), 0); - - // Open active object for reading from stdin. - STDIN_Handler stdin_handler (peer_handler); - - // Spawn thread. - if (stdin_handler.open () == -1) - ACE_ERROR_RETURN ((LM_ERROR, - "%p open failed, errno = %d.\n", - "stdin_handler", errno), 0); - - // Register proactor with ReactorEx so that we can demultiplex - // "waitable" events and I/O operations from a single thread. - if (ACE_Service_Config::reactorEx ()->register_handler - (ACE_Service_Config::proactor ()) != 0) - ACE_ERROR_RETURN ((LM_ERROR, "%p failed to register Proactor.\n", - argv[0]), -1); - - // Run main event demultiplexor. - ACE_Service_Config::run_reactorEx_event_loop (); - - return 0; -} diff --git a/examples/Reactor/ReactorEx/test_remove_handler.cpp b/examples/Reactor/ReactorEx/test_remove_handler.cpp deleted file mode 100644 index 3b0ef3906bb..00000000000 --- a/examples/Reactor/ReactorEx/test_remove_handler.cpp +++ /dev/null @@ -1,94 +0,0 @@ -// ============================================================================ -// $Id$ - -// -// = LIBRARY -// examples -// -// = FILENAME -// test_remove_handler.cpp -// -// = DESCRIPTION -// Tests the ReactorEx's ability to handle simultaneous events. If -// you pass anything on the command-line, then each handler -// requests to be removed from the ReactorEx after each event. -// This has a funky effect on the order in which handlers are -// serviced. So, if no parameters are passed in, the handlers -// should be serviced 1 through MAXIMUM_WAIT_OBJECTS. If handlers -// to request to be removed as signals occur, they will be serviced -// 1, MAX, MAX-1, ..., 2. This is because of a ReactorEx -// bookkeeping optimization. -// -// = AUTHOR -// Tim Harrison -// -// ============================================================================ - -#include "ace/ReactorEx.h" -#include "ace/Service_Config.h" -#include "ace/Synch.h" - -class Event_Handler : public ACE_Event_Handler -// = TITLE -// Generic Event Handler. -// -// = DESCRIPTION -// -// Creates event. Registers with ReactorEx. Signals event. If -// created with -close_down- it returns -1 from handle signal. -{ -public: - Event_Handler (int event_number, - int close_down) - : event_number_ (event_number), - close_down_ (close_down) - { - ACE_Service_Config::reactorEx ()->register_handler (this, - this->event_.handle ()); - this->event_.signal (); - } - - virtual int handle_signal (int index, siginfo_t *, ucontext_t *) - { - ACE_DEBUG ((LM_DEBUG, "event %d occured.\n", event_number_)); - - if (this->close_down_) - return -1; - else - return 0; - } - - virtual int handle_close (ACE_HANDLE, ACE_Reactor_Mask) - { - // ACE_DEBUG ((LM_DEBUG, "event handler %d closed.\n", event_number_)); - delete this; - return 0; - } - - virtual ACE_HANDLE get_handle (void) const - { - return event_.handle (); - } - -private: - int event_number_; - // Our event number. - - int close_down_; - // Shall we close down or not. - - ACE_Event event_; - // Signaled to shut down the handler. -}; - -int -main (int argc, char *argv[]) -{ - int close_down = argc > 1 ? 1 : 0; - - for (int i = 0; i < ACE_ReactorEx::MAX_SIZE; i++) - new Event_Handler (i, close_down); - - ACE_Service_Config::reactorEx ()->handle_events (); - return 42; -} diff --git a/examples/Reactor/ReactorEx/test_timeout.cpp b/examples/Reactor/ReactorEx/test_timeout.cpp deleted file mode 100644 index 44871a2db2d..00000000000 --- a/examples/Reactor/ReactorEx/test_timeout.cpp +++ /dev/null @@ -1,72 +0,0 @@ -// ============================================================================ -// $Id: test_timeout.cpp - -// -// = LIBRARY -// examples -// -// = FILENAME -// test_timeout.cpp -// -// = DESCRIPTION -// This example application shows how to write ReactorEx and -// Proactor event loops that handle events for some fixed amount of -// time. -// -// = AUTHOR -// Tim Harrison -// -// ============================================================================ - -#include "ace/ReactorEx.h" -#include "ace/Proactor.h" -#include "ace/Time_Value.h" -#include "ace/Service_Config.h" -#include "ace/OS.h" - -class Timeout_Handler : public ACE_Event_Handler -// = TITLE -// Generic timeout handler. -{ -public: - Timeout_Handler (void) : count_ (0) {;} - - virtual int handle_timeout (const ACE_Time_Value &tv, - const void *arg) - // Print out when timeouts occur. - { - ACE_DEBUG ((LM_DEBUG, "%d timeout occurred for %s.\n", - ++count_, - (char *) arg)); - return 0; - } - -private: - int count_; -}; - -int -main () -{ - Timeout_Handler handler; - - // Register a 2 second timer. - ACE_Time_Value foo_tv (2); - ACE_Service_Config::reactorEx ()->schedule_timer (&handler, - (void *) "Foo", - ACE_Time_Value::zero, - foo_tv); - // Register a 3 second timer. - ACE_Time_Value bar_tv (3); - ACE_Service_Config::reactorEx ()->schedule_timer (&handler, - (void *) "Bar", - ACE_Time_Value::zero, - bar_tv); - - // Handle events for 12 seconds. - ACE_Time_Value run_time (12); - if (ACE_Service_Config::run_reactorEx_event_loop (run_time) == -1) - ACE_ERROR_RETURN ((LM_ERROR, "%p.\n", "main"), -1); - - return 0; -} |