summaryrefslogtreecommitdiff
path: root/examples/APG
diff options
context:
space:
mode:
authorJohnny Willemsen <jwillemsen@remedy.nl>2004-04-27 07:29:43 +0000
committerJohnny Willemsen <jwillemsen@remedy.nl>2004-04-27 07:29:43 +0000
commit63f79a06d714be81ad6ff21d6fefc55e1cfa7609 (patch)
treec2d5f97884c5764acb984f207ae987cc7d8be566 /examples/APG
parent221d4f1cd0dcdfeeeebf48c265af2e7a16e11139 (diff)
downloadATCD-63f79a06d714be81ad6ff21d6fefc55e1cfa7609.tar.gz
ChangeLogTag: Tue Apr 27 08:18:23 UTC 2004 Johnny Willemsen <jwillemsen@remedy.nl>
Diffstat (limited to 'examples/APG')
-rw-r--r--examples/APG/ThreadPools/TP_Reactor.cpp8
-rw-r--r--examples/APG/Threads/Message_Queue.cpp36
2 files changed, 22 insertions, 22 deletions
diff --git a/examples/APG/ThreadPools/TP_Reactor.cpp b/examples/APG/ThreadPools/TP_Reactor.cpp
index 5d574a59d50..1c7a0cc36e4 100644
--- a/examples/APG/ThreadPools/TP_Reactor.cpp
+++ b/examples/APG/ThreadPools/TP_Reactor.cpp
@@ -64,7 +64,7 @@ Request_Handler::handle_input (ACE_HANDLE fd)
fd,
buffer));
if (ACE_OS::strcmp (buffer, ACE_TEXT ("shutdown")) == 0)
- ACE_Reactor::end_event_loop ();
+ ACE_Reactor::instance()->end_reactor_event_loop ();
return 0;
}
else
@@ -81,14 +81,14 @@ Request_Handler::handle_close (ACE_HANDLE fd, ACE_Reactor_Mask)
ACE_TEXT ("(%t) svr close; fd: 0x%x, rcvd %d msgs\n"),
fd,
this->nr_msgs_rcvd_));
-
+
if (this->nr_msgs_rcvd_ != cli_req_no)
ACE_ERROR((LM_ERROR,
ACE_TEXT ("(%t) Handler 0x%x: Expected %d messages; got %d\n"),
this,
cli_req_no,
this->nr_msgs_rcvd_));
-
+
this->destroy ();
return 0;
}
@@ -141,7 +141,7 @@ class Client: public ACE_Task_Base
ACE_OS::sleep (3);
const ACE_TCHAR *msg =
ACE_TEXT ("Message from Connection worker");
-
+
ACE_TCHAR buf [BUFSIZ];
buf[0] = ACE_OS::strlen (msg) + 1;
ACE_OS::strcpy (&buf[1], msg);
diff --git a/examples/APG/Threads/Message_Queue.cpp b/examples/APG/Threads/Message_Queue.cpp
index f6315c13c48..c58c1a82b7a 100644
--- a/examples/APG/Threads/Message_Queue.cpp
+++ b/examples/APG/Threads/Message_Queue.cpp
@@ -5,7 +5,7 @@
#include "Message_Receiver.h"
// Listing 5 code/ch12
-int
+int
HA_CommandHandler::svc (void)
{
while(1)
@@ -24,7 +24,7 @@ HA_CommandHandler::svc (void)
DeviceCommandHeader *dch
= (DeviceCommandHeader*)mb->rd_ptr ();
mb->rd_ptr (sizeof (DeviceCommandHeader));
- ACE_DEBUG ((LM_DEBUG,
+ ACE_DEBUG ((LM_DEBUG,
ACE_TEXT ("Message for device #%d with ")
ACE_TEXT ("command payload of:\n%s"),
dch->deviceId_, mb->rd_ptr ()));
@@ -41,7 +41,7 @@ HA_CommandHandler::svc (void)
// Listing 5
// Listing 4 code/ch12
-ACE_Message_Block *
+ACE_Message_Block *
Message_Receiver::shut_down_message (void)
{
ACE_Message_Block *mb;
@@ -50,11 +50,11 @@ Message_Receiver::shut_down_message (void)
return mb;
}
// Listing 4
-
-int
+
+int
Message_Receiver::read_header (DeviceCommandHeader *dch)
{
- ssize_t result =
+ ssize_t result =
this->peer ().recv_n (dch, sizeof (DeviceCommandHeader));
if (result <= 0)
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
@@ -63,13 +63,13 @@ Message_Receiver::read_header (DeviceCommandHeader *dch)
return 0;
}
// Listing 3 code/ch12
-int
+int
Message_Receiver::copy_payload (ACE_Message_Block *mb,
int payload_length)
{
- int result =
+ int result =
this->peer ().recv_n (mb->wr_ptr (), payload_length);
-
+
if (result <= 0)
{
mb->release ();
@@ -81,20 +81,20 @@ Message_Receiver::copy_payload (ACE_Message_Block *mb,
}
// Listing 3
// Listing 2 code/ch12
-int
+int
Message_Receiver::handle_input (ACE_HANDLE)
{
DeviceCommandHeader dch;
if (this->read_header (&dch) < 0)
return -1;
-
+
if (dch.deviceId_ < 0)
{
// Handle shutdown.
this->handler_->putq (shut_down_message ());
return -1;
}
-
+
ACE_Message_Block *mb;
ACE_NEW_RETURN
(mb, ACE_Message_Block (dch.length_ + sizeof dch), -1);
@@ -120,7 +120,7 @@ static void report_usage (int argc, ACE_TCHAR *argv[])
}
-class Acceptor : public ACE_Acceptor<Message_Receiver, ACE_SOCK_ACCEPTOR>
+class Acceptor : public ACE_Acceptor<Message_Receiver, ACE_SOCK_ACCEPTOR>
{
public:
Acceptor(HA_CommandHandler *handler) : handler_(handler)
@@ -142,21 +142,21 @@ int ACE_TMAIN (int argc, ACE_TCHAR *argv[])
report_usage (argc, argv);
u_short port = ACE_OS::atoi (argv[1]);
-
+
HA_Device_Repository rep;
HA_CommandHandler handler (rep);
ACE_ASSERT(handler.activate()==0);
//start up the handler.
-
+
Acceptor acceptor (&handler);
ACE_INET_Addr addr (port);
if (acceptor.open (addr) == -1)
ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"),
ACE_TEXT ("Failed to open connection")), -1);
-
- ACE_Reactor::run_event_loop ();
+
+ ACE_Reactor::instance()->run_reactor_event_loop ();
//run the reactive event loop
-
+
handler.wait ();
//reap the handler before exiting.