From d75e099e35d9a59ba843b70267277235a353ea3e Mon Sep 17 00:00:00 2001 From: Chris Frey Date: Fri, 3 Sep 2010 17:56:36 -0400 Subject: [PATCH] lib: wrap shared_ptr<> in a typedef as SocketDataHandlerPtr --- src/m_raw_channel.cc | 2 +- src/m_serial.cc | 4 ++-- src/router.cc | 10 +++++----- src/router.h | 8 +++++--- src/socket.cc | 2 +- 5 files changed, 14 insertions(+), 12 deletions(-) diff --git a/src/m_raw_channel.cc b/src/m_raw_channel.cc index f78b7692..da6e6291 100644 --- a/src/m_raw_channel.cc +++ b/src/m_raw_channel.cc @@ -145,7 +145,7 @@ void RawChannel::OnOpen() // implemented m_zero_registered = true; m_socket->HideSequencePacket(false); - std::tr1::shared_ptr callback; + SocketRoutingQueue::SocketDataHandlerPtr callback; callback.reset(new RawChannelSocketHandler(*this)); m_con.m_queue->RegisterInterest(0, callback); // Get socket data packets routed to this class as well if using callback diff --git a/src/m_serial.cc b/src/m_serial.cc index 363ef632..fb18d379 100644 --- a/src/m_serial.cc +++ b/src/m_serial.cc @@ -101,10 +101,10 @@ void Serial::Open(const char *password) m_ctrl = m_con.m_zero.Open(m_CtrlSocket, password); // register callback for incoming data, for speed - std::tr1::shared_ptr data_callback + SocketRoutingQueue::SocketDataHandlerPtr data_callback (new SocketRoutingQueue::SimpleSocketDataHandler(*this, DataCallback)); m_data->RegisterInterest(data_callback); - std::tr1::shared_ptr ctrl_callback + SocketRoutingQueue::SocketDataHandlerPtr ctrl_callback (new SocketRoutingQueue::SimpleSocketDataHandler(*this, CtrlCallback)); m_ctrl->RegisterInterest(ctrl_callback); diff --git a/src/router.cc b/src/router.cc index cc5c2d1c..99ecdc59 100644 --- a/src/router.cc +++ b/src/router.cc @@ -208,7 +208,7 @@ DataHandle SocketRoutingQueue::DefaultRead(int timeout) /// Throws std::logic_error if already registered. /// void SocketRoutingQueue::RegisterInterest(SocketId socket, - std::tr1::shared_ptr handler) + SocketDataHandlerPtr handler) { // modifying our own std::map, need a lock scoped_lock lock(m_mutex); @@ -412,7 +412,7 @@ void SocketRoutingQueue::DoRead(int timeout) if( m_interest ) { SocketQueueMap::iterator qi = m_socketQueues.find(socket); if( qi != m_socketQueues.end() ) { - std::tr1::shared_ptr &sdh = qi->second->m_handler; + SocketDataHandlerPtr &sdh = qi->second->m_handler; // is there a handler? if( sdh ) { @@ -446,10 +446,10 @@ void SocketRoutingQueue::DoRead(int timeout) // Can't be locked when calling the callback, so need // to make a list of them first. scoped_lock lock(m_mutex); - std::vector > handlers; + std::vector handlers; SocketQueueMap::iterator qi = m_socketQueues.begin(); while( qi != m_socketQueues.end() ) { - std::tr1::shared_ptr &sdh = qi->second->m_handler; + SocketDataHandlerPtr &sdh = qi->second->m_handler; // is there a handler? if( sdh ) { handlers.push_back(sdh); @@ -457,7 +457,7 @@ void SocketRoutingQueue::DoRead(int timeout) ++qi; } lock.unlock(); - std::vector >::iterator hi = handlers.begin(); + std::vector::iterator hi = handlers.begin(); while( hi != handlers.end() ) { (*hi)->Error(ue); ++hi; diff --git a/src/router.h b/src/router.h index 8293a260..86b3cba3 100644 --- a/src/router.h +++ b/src/router.h @@ -64,6 +64,8 @@ public: virtual ~SocketDataHandler(); }; + typedef std::tr1::shared_ptr SocketDataHandlerPtr; + // Simple wrapper template class for SocketDataHandler which provides a basic data recieved callback template class SimpleSocketDataHandler : public SocketDataHandler { @@ -82,10 +84,10 @@ public: struct QueueEntry { - std::tr1::shared_ptr m_handler; + SocketDataHandlerPtr m_handler; DataQueue m_queue; - QueueEntry(std::tr1::shared_ptr h) + QueueEntry(SocketDataHandlerPtr h) : m_handler(h) {} }; @@ -171,7 +173,7 @@ public: // copying is done. Once the handler returns, the data is // considered processed and not added to the interested queue, // but instead returned to m_free. - void RegisterInterest(SocketId socket, std::tr1::shared_ptr handler); + void RegisterInterest(SocketId socket, SocketDataHandlerPtr handler); // Unregisters interest in data from the given socket, and discards // any existing data in its interest queue. Any new incoming data diff --git a/src/socket.cc b/src/socket.cc index 5704cafc..84fd3a0b 100644 --- a/src/socket.cc +++ b/src/socket.cc @@ -1098,7 +1098,7 @@ void Socket::NextRecord(Data &receive) Packet(command, receive); } -void Socket::RegisterInterest(std::tr1::shared_ptr handler) +void Socket::RegisterInterest(SocketRoutingQueue::SocketDataHandlerPtr handler) { if( !m_zero->m_queue ) throw std::logic_error("SocketRoutingQueue required in SocketZero in order to call Socket::RegisterInterest()"); -- 2.11.4.GIT