move localRefCount accounting responsibility from Peer to Peers

This makes for a more symmetric API - Peers.FetchWithDefault does the
increment and Peers.Dereference does the decrement, whereas previously
the latter was done by Peer.DecrementLocalRefCount.

This does increase lock granularity, i.e. modifying any ref count now
requires a write lock on Peers.
This commit is contained in:
Matthias Radestock committed 2015-05-11 17:19:23 +01:00
1 parent 3e6eef5ebd
commit 505ced5cc8
5 files changed
+19 -45

No files matched your search

+2 -2
View File
@@ -55,8 +55,8 @@ func (router *Router) DeleteTestChannelConnection(r *Router) {
fromPeer, _ := r.Peers.Fetch(fromName)
toPeer, _ := router.Peers.Fetch(toName)
fromPeer.DecrementLocalRefCount()
toPeer.DecrementLocalRefCount()
r.Peers.Dereference(fromPeer)
router.Peers.Dereference(toPeer)
conn, _ := router.Ourself.ConnectionTo(toName)
router.Ourself.handleDeleteConnection(conn)