diff options
author | Andreas Hansson <andreas.hansson@arm.com> | 2014-10-16 05:49:49 -0400 |
---|---|---|
committer | Andreas Hansson <andreas.hansson@arm.com> | 2014-10-16 05:49:49 -0400 |
commit | db3739682d7c54839b627ff8f7a4448a9dc99987 (patch) | |
tree | ef5e44342d585e102e2dd4b5503b0111bb8ce35f /src/mem/ruby/slicc_interface | |
parent | acdfcad30de8dcf59515b688a1310ba2c1ca6947 (diff) | |
download | gem5-db3739682d7c54839b627ff8f7a4448a9dc99987.tar.xz |
mem: Use shared_ptr for Ruby Message classes
This patch transitions the Ruby Message and its derived classes from
the ad-hoc RefCountingPtr to the c++11 shared_ptr. There are no
changes in behaviour, and the code modifications are mainly replacing
"new" with "make_shared".
The cloning of derived messages is slightly changed as they previously
relied on overriding the base-class through covariant return types.
Diffstat (limited to 'src/mem/ruby/slicc_interface')
-rw-r--r-- | src/mem/ruby/slicc_interface/Message.hh | 8 | ||||
-rw-r--r-- | src/mem/ruby/slicc_interface/NetworkMessage.hh | 3 | ||||
-rw-r--r-- | src/mem/ruby/slicc_interface/RubyRequest.hh | 3 |
3 files changed, 8 insertions, 6 deletions
diff --git a/src/mem/ruby/slicc_interface/Message.hh b/src/mem/ruby/slicc_interface/Message.hh index 1c842ae69..786c656bc 100644 --- a/src/mem/ruby/slicc_interface/Message.hh +++ b/src/mem/ruby/slicc_interface/Message.hh @@ -30,14 +30,14 @@ #define __MEM_RUBY_SLICC_INTERFACE_MESSAGE_HH__ #include <iostream> +#include <memory> -#include "base/refcnt.hh" #include "mem/packet.hh" class Message; -typedef RefCountingPtr<Message> MsgPtr; +typedef std::shared_ptr<Message> MsgPtr; -class Message : public RefCounted +class Message { public: Message(Tick curTime) @@ -54,7 +54,7 @@ class Message : public RefCounted virtual ~Message() { } - virtual Message* clone() const = 0; + virtual MsgPtr clone() const = 0; virtual void print(std::ostream& out) const = 0; virtual void setIncomingLink(int) {} virtual void setVnet(int) {} diff --git a/src/mem/ruby/slicc_interface/NetworkMessage.hh b/src/mem/ruby/slicc_interface/NetworkMessage.hh index 10d78251a..1b5edcfcd 100644 --- a/src/mem/ruby/slicc_interface/NetworkMessage.hh +++ b/src/mem/ruby/slicc_interface/NetworkMessage.hh @@ -30,13 +30,14 @@ #define __MEM_RUBY_SLICC_INTERFACE_NETWORKMESSAGE_HH__ #include <iostream> +#include <memory> #include "mem/protocol/MessageSizeType.hh" #include "mem/ruby/common/NetDest.hh" #include "mem/ruby/slicc_interface/Message.hh" class NetworkMessage; -typedef RefCountingPtr<NetworkMessage> NetMsgPtr; +typedef std::shared_ptr<NetworkMessage> NetMsgPtr; class NetworkMessage : public Message { diff --git a/src/mem/ruby/slicc_interface/RubyRequest.hh b/src/mem/ruby/slicc_interface/RubyRequest.hh index 49964ebb9..357eddbb5 100644 --- a/src/mem/ruby/slicc_interface/RubyRequest.hh +++ b/src/mem/ruby/slicc_interface/RubyRequest.hh @@ -71,7 +71,8 @@ class RubyRequest : public Message } RubyRequest(Tick curTime) : Message(curTime) {} - RubyRequest* clone() const { return new RubyRequest(*this); } + MsgPtr clone() const + { return std::shared_ptr<Message>(new RubyRequest(*this)); } const Address& getLineAddress() const { return m_LineAddress; } const Address& getPhysicalAddress() const { return m_PhysicalAddress; } |