github.com/keltia/go-ipfs@v0.3.8-0.20150909044612-210793031c63/routing/dht/util.go (about) 1 package dht 2 3 import ( 4 "sync" 5 ) 6 7 // Pool size is the number of nodes used for group find/set RPC calls 8 var PoolSize = 6 9 10 // K is the maximum number of requests to perform before returning failure. 11 var KValue = 10 12 13 // Alpha is the concurrency factor for asynchronous requests. 14 var AlphaValue = 3 15 16 // A counter for incrementing a variable across multiple threads 17 type counter struct { 18 n int 19 mut sync.Mutex 20 } 21 22 func (c *counter) Increment() { 23 c.mut.Lock() 24 c.n++ 25 c.mut.Unlock() 26 } 27 28 func (c *counter) Decrement() { 29 c.mut.Lock() 30 c.n-- 31 c.mut.Unlock() 32 } 33 34 func (c *counter) Size() (s int) { 35 c.mut.Lock() 36 s = c.n 37 c.mut.Unlock() 38 return 39 }