2010-11-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>

Added BtSeederStateChoke::PeerEntry::swap(). Also added
	non-member swap for it, which is friend function for
	BtSeederStateChoke because PeerEntry is private.
	* src/BtSeederStateChoke.cc
	* src/BtSeederStateChoke.h
pull/1/head
Tatsuhiro Tsujikawa 2010-11-20 15:01:24 +00:00
parent 8f46dbc0ab
commit 752234ae66
3 changed files with 51 additions and 0 deletions

View File

@ -1,3 +1,11 @@
2010-11-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added BtSeederStateChoke::PeerEntry::swap(). Also added
non-member swap for it, which is friend function for
BtSeederStateChoke because PeerEntry is private.
* src/BtSeederStateChoke.cc
* src/BtSeederStateChoke.h
2010-11-20 Tatsuhiro Tsujikawa <t-tujikawa@users.sourceforge.net>
Added BtLeecherStateChoke::PeerEntry::swap(). Also added

View File

@ -71,6 +71,16 @@ BtSeederStateChoke::PeerEntry::PeerEntry(const PeerEntry& c)
BtSeederStateChoke::PeerEntry::~PeerEntry() {}
void BtSeederStateChoke::PeerEntry::swap(PeerEntry& c)
{
using std::swap;
swap(peer_, c.peer_);
swap(outstandingUpload_, c.outstandingUpload_);
swap(lastAmUnchoking_, c.lastAmUnchoking_);
swap(recentUnchoking_, c.recentUnchoking_);
swap(uploadSpeed_, c.uploadSpeed_);
}
BtSeederStateChoke::PeerEntry& BtSeederStateChoke::PeerEntry::operator=
(const PeerEntry& c)
{
@ -176,4 +186,21 @@ BtSeederStateChoke::executeChoke
}
}
void swap
(BtSeederStateChoke::PeerEntry& a,
BtSeederStateChoke::PeerEntry& b)
{
a.swap(b);
}
} // namespace aria2
namespace std {
template<>
void swap<aria2::BtSeederStateChoke::PeerEntry>
(aria2::BtSeederStateChoke::PeerEntry& a,
aria2::BtSeederStateChoke::PeerEntry& b)
{
a.swap(b);
}
} // namespace std

View File

@ -66,6 +66,8 @@ private:
PeerEntry(const PeerEntry& c);
~PeerEntry();
void swap(PeerEntry& c);
PeerEntry& operator=(const PeerEntry& c);
bool operator<(const PeerEntry& rhs) const;
@ -99,8 +101,22 @@ public:
void executeChoke(const std::vector<SharedHandle<Peer> >& peerSet);
const Timer& getLastRound() const { return lastRound_; }
friend void swap(PeerEntry& a, PeerEntry& b);
friend void std::swap<PeerEntry>(PeerEntry& a, PeerEntry& b);
};
void swap
(BtSeederStateChoke::PeerEntry& a,
BtSeederStateChoke::PeerEntry& b);
} // namespace aria2
namespace std {
template<>
void swap<aria2::BtSeederStateChoke::PeerEntry>
(aria2::BtSeederStateChoke::PeerEntry& a,
aria2::BtSeederStateChoke::PeerEntry& b);
} // namespace std
#endif // D_BT_SEEDER_STATE_CHOKE_H