Skip to content

Commit

Permalink
2010-11-20 Tatsuhiro Tsujikawa <[email protected]>
Browse files Browse the repository at this point in the history
	Added BtLeecherStateChoke::PeerEntry::swap(). Also added
	non-member swap for it, which is friend function for
	BtLeecherStateChoke because PeerEntry is private.
	* src/BtLeecherStateChoke.cc
	* src/BtLeecherStateChoke.h
  • Loading branch information
tatsuhiro-t committed Nov 20, 2010
1 parent 4ed364d commit 8f46dbc
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
8 changes: 8 additions & 0 deletions ChangeLog
Original file line number Diff line number Diff line change
@@ -1,3 +1,11 @@
2010-11-20 Tatsuhiro Tsujikawa <[email protected]>

Added BtLeecherStateChoke::PeerEntry::swap(). Also added
non-member swap for it, which is friend function for
BtLeecherStateChoke because PeerEntry is private.
* src/BtLeecherStateChoke.cc
* src/BtLeecherStateChoke.h

2010-11-20 Tatsuhiro Tsujikawa <[email protected]>

Added CookieStorage::DomainEntry::swap(). Also added non-member
Expand Down
25 changes: 25 additions & 0 deletions src/BtLeecherStateChoke.cc
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ BtLeecherStateChoke::PeerEntry::PeerEntry(const PeerEntry& c)
regularUnchoker_(c.regularUnchoker_)
{}

void BtLeecherStateChoke::PeerEntry::swap(PeerEntry& c)
{
using std::swap;
swap(peer_, c.peer_);
swap(downloadSpeed_, c.downloadSpeed_);
swap(regularUnchoker_, c.regularUnchoker_);
}

BtLeecherStateChoke::PeerEntry& BtLeecherStateChoke::PeerEntry::operator=
(const PeerEntry& c)
{
Expand Down Expand Up @@ -123,6 +131,13 @@ bool BtLeecherStateChoke::PeerEntry::operator<(const PeerEntry& peerEntry) const
return downloadSpeed_ > peerEntry.downloadSpeed_;
}

void swap
(BtLeecherStateChoke::PeerEntry& a,
BtLeecherStateChoke::PeerEntry& b)
{
a.swap(b);
}

bool BtLeecherStateChoke::PeerFilter::operator()
(const PeerEntry& peerEntry) const
{
Expand Down Expand Up @@ -224,3 +239,13 @@ const Timer& BtLeecherStateChoke::getLastRound() const
}

} // namespace aria2

namespace std {
template<>
void swap<aria2::BtLeecherStateChoke::PeerEntry>
(aria2::BtLeecherStateChoke::PeerEntry& a,
aria2::BtLeecherStateChoke::PeerEntry& b)
{
a.swap(b);
}
} // namespace std;
16 changes: 16 additions & 0 deletions src/BtLeecherStateChoke.h
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@ class BtLeecherStateChoke {

bool operator<(const PeerEntry& rhs) const;

void swap(PeerEntry& c);

const SharedHandle<Peer>& getPeer() const;

unsigned int getDownloadSpeed() const;
Expand Down Expand Up @@ -114,8 +116,22 @@ class BtLeecherStateChoke {
void executeChoke(const std::vector<SharedHandle<Peer> >& peerSet);

const Timer& getLastRound() const;

friend void swap(PeerEntry& a, PeerEntry& b);
friend void std::swap<PeerEntry>(PeerEntry& a, PeerEntry& b);
};

void swap
(BtLeecherStateChoke::PeerEntry& a,
BtLeecherStateChoke::PeerEntry& b);

} // namespace aria2

namespace std {
template<>
void swap<aria2::BtLeecherStateChoke::PeerEntry>
(aria2::BtLeecherStateChoke::PeerEntry& a,
aria2::BtLeecherStateChoke::PeerEntry& b);
} // namespace std

#endif // D_BT_LEECHER_STATE_CHOKE_H

0 comments on commit 8f46dbc

Please sign in to comment.