-
Notifications
You must be signed in to change notification settings - Fork 36
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
- Loading branch information
Vladimir Popov
committed
Dec 2, 2020
1 parent
7936339
commit 603d83c
Showing
3 changed files
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
# clientmap.Map | ||
|
||
It is a `sync.Map` typed for the `string` keys and `networkservice.NetworkServiceClient` values. | ||
|
||
# clientmap.RefcountMap | ||
|
||
It is a `clientmap.Map` wrapped with refcounting: | ||
``` | ||
Store, LoadOrStore (store) --> count = 1 | ||
Load, LoadOrStore (load) --> count += 1 | ||
LoadAndDelete, Delete --> count -= 1 | ||
``` | ||
if count becomes 0, value deletes. | ||
|
||
## Performance | ||
|
||
`clientmap.RefcountMap` is a very thin wrapper, it doesn't hardly affect the `clientmap.Map` performance: | ||
``` | ||
BenchmarkMap | ||
BenchmarkMap-4 15998454 84.6 ns/op | ||
BenchmarkRefcountMap | ||
BenchmarkRefcountMap-4 10496374 106 ns/op | ||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters