From: tho Date: Mon, 6 Sep 2010 11:52:24 +0000 (+0000) Subject: Packets: internal pointer access optimization in ConcretePacket X-Git-Url: http://g0dil.de/git?a=commitdiff_plain;h=14f43d9587103f6a78e51628785f93f1c14f99a0;p=senf.git Packets: internal pointer access optimization in ConcretePacket PPI: some minor optimizations git-svn-id: https://svn.berlios.de/svnroot/repos/senf/trunk@1709 270642c3-0616-0410-b53a-bc976706d245 --- diff --git a/senf/PPI/Connectors.cti b/senf/PPI/Connectors.cti index 9a756b9..2b36442 100644 --- a/senf/PPI/Connectors.cti +++ b/senf/PPI/Connectors.cti @@ -37,15 +37,15 @@ template prefix_ typename senf::ppi::connector::detail::TypedInputMixin::Type senf::ppi::connector::detail::TypedInputMixin::operator()() { - return read(); + Packet p (static_cast(this)->InputConnector::operator()()); + return p ? p.as() : Type(); } template prefix_ typename senf::ppi::connector::detail::TypedInputMixin::Type senf::ppi::connector::detail::TypedInputMixin::read() { - Packet p (static_cast(this)->InputConnector::read()); - return p ? p.as() : Type(); + return operator()(); } /////////////////////////////////////////////////////////////////////////// diff --git a/senf/PPI/Connectors.hh b/senf/PPI/Connectors.hh index 6b4cdef..41994e1 100644 --- a/senf/PPI/Connectors.hh +++ b/senf/PPI/Connectors.hh @@ -670,8 +670,8 @@ namespace connector { class ActiveOutput : public GenericActiveOutput { public: - operator()(PacketType packet); ///< Send out a packet - void write(PacketType packet); ///< Alias for operator() + void operator()(PacketType packet); ///< Send out a packet + void write(PacketType packet); ///< Alias for operator() }; /** \brief Connector passively providing packets @@ -690,8 +690,8 @@ namespace connector { class PassiveOutput : public GenericPassiveOutput { public: - operator()(PacketType packet); ///< Send out a packet - void write(PacketType packet); ///< Alias for operator() + void operator()(PacketType packet); ///< Send out a packet + void write(PacketType packet); ///< Alias for operator() }; #endif diff --git a/senf/PPI/QueueingSocketSink.ct b/senf/PPI/QueueingSocketSink.ct index 2d991c6..6a1e831 100644 --- a/senf/PPI/QueueingSocketSink.ct +++ b/senf/PPI/QueueingSocketSink.ct @@ -79,7 +79,7 @@ prefix_ senf::ppi::module::PassiveQueueingSocketSink::PassiveQueueingSoc template prefix_ void senf::ppi::module::PassiveQueueingSocketSink::write() { - PacketType p ( input.read()); + PacketType p ( input()); if (qAlgo_->size() > 0) { qAlgo_->enqueue( p); return; diff --git a/senf/Packets/Packet.cti b/senf/Packets/Packet.cti index 0241419..902681b 100644 --- a/senf/Packets/Packet.cti +++ b/senf/Packets/Packet.cti @@ -327,11 +327,10 @@ prefix_ senf::ConcretePacket::ConcretePacket(typename interpreter::p {} template -prefix_ typename senf::ConcretePacket::interpreter::ptr -senf::ConcretePacket::ptr() +prefix_ typename senf::ConcretePacket::interpreter * senf::ConcretePacket::ptr() const { - return boost::static_pointer_cast< PacketInterpreter >(Packet::ptr()); + return static_cast< PacketInterpreter *>( Packet::ptr().get()); } ///////////////////////////////cti.e/////////////////////////////////////// diff --git a/senf/Packets/Packet.hh b/senf/Packets/Packet.hh index 7d31942..090cd66 100644 --- a/senf/Packets/Packet.hh +++ b/senf/Packets/Packet.hh @@ -405,7 +405,7 @@ namespace senf { when using a packet in a boolean context. */ void finalizeThis(); ///< Update calculated fields - /**< The finalize() fammily of members will update + /**< The finalize() family of members will update calculated packet fields: checksums, size fields and so on. This includes any field, which can be set from other information in the packet. Each concrete packet @@ -420,7 +420,7 @@ namespace senf { template void finalizeTo(); ///< Update calculated fields - /**< The finalize() fammily of members will update + /**< The finalize() family of members will update calculated packet fields: checksums, size fields and so on. This includes any field, which can be set from other information in the packet. Each concrete packet @@ -439,7 +439,7 @@ namespace senf { \endcode */ void finalizeTo(Packet const & other); ///< Update calculated fields - /**< The finalize() fammily of members will update + /**< The finalize() family of members will update calculated packet fields: checksums, size fields and so on. This includes any field, which can be set from other information in the packet. Each concrete packet @@ -762,7 +762,7 @@ namespace senf { ConcretePacket(typename interpreter::ptr const & packet_); - typename interpreter::ptr ptr() const; + interpreter * ptr() const; friend class Packet; friend class PacketInterpreter; diff --git a/senf/Packets/PacketImpl.cc b/senf/Packets/PacketImpl.cc index b1c9791..0c38d46 100644 --- a/senf/Packets/PacketImpl.cc +++ b/senf/Packets/PacketImpl.cc @@ -167,6 +167,18 @@ prefix_ void * senf::detail::PacketImpl::complexAnnotation(AnnotationRegistry::k /////////////////////////////////////////////////////////////////////////// // senf::detail::AnnotationRegistry +prefix_ void senf::detail::AnnotationRegistry::dump(key_type key, std::ostream & os, + void * annotation) + const +{ + Registry::const_iterator i (registry_.find(key)); + if (i != registry_.end()) { + os << fieldName(i->second->v_name()); + i->second->v_dump(os, annotation); + os << "\n"; + } +} + prefix_ void senf::detail::AnnotationRegistry::dumpRegistrations(std::ostream & os) { boost::format fmt ("%-56.56s %-4.4s %-7.7s %5d\n"); diff --git a/senf/Packets/PacketImpl.cci b/senf/Packets/PacketImpl.cci index 70ac003..2cc4f67 100644 --- a/senf/Packets/PacketImpl.cci +++ b/senf/Packets/PacketImpl.cci @@ -33,18 +33,6 @@ /////////////////////////////////////////////////////////////////////////// // senf::detail::AnnotationRegistry -prefix_ void senf::detail::AnnotationRegistry::dump(key_type key, std::ostream & os, - void * annotation) - const -{ - Registry::const_iterator i (registry_.find(key)); - if (i != registry_.end()) { - os << fieldName(i->second->v_name()); - i->second->v_dump(os, annotation); - os << "\n"; - } -} - prefix_ std::string senf::detail::AnnotationRegistry::name(key_type key) const { diff --git a/senf/Packets/PacketInterpreter.cc b/senf/Packets/PacketInterpreter.cc index 77627d3..cb94b8d 100644 --- a/senf/Packets/PacketInterpreter.cc +++ b/senf/Packets/PacketInterpreter.cc @@ -110,7 +110,7 @@ prefix_ void senf::PacketInterpreterBase::add_ref() intrusive_refcount_t::add_ref(); } -prefix_ bool senf::PacketInterpreterBase::release() +prefix_ void senf::PacketInterpreterBase::release() { if (impl_ && refcount()==1) // This call will set impl_ to 0 if we just removed the last reference ... diff --git a/senf/Packets/PacketInterpreter.hh b/senf/Packets/PacketInterpreter.hh index d8fd813..fa9ed46 100644 --- a/senf/Packets/PacketInterpreter.hh +++ b/senf/Packets/PacketInterpreter.hh @@ -214,7 +214,7 @@ namespace senf { // reference/memory management. Only to be called by intrusive_refcount_t. void add_ref(); - bool release(); + void release(); // containment management. Only to be called by PacketImpl.