Skip to content

Commit

Permalink
Add README, fix copyright issues
Browse files Browse the repository at this point in the history
Signed-off-by: Vladimir Popov <vladimir.popov@xored.com>
  • Loading branch information
Vladimir Popov committed Dec 2, 2020
1 parent 7936339 commit 603d83c
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 0 deletions.
23 changes: 23 additions & 0 deletions pkg/tools/clientmap/README.md
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
```
2 changes: 2 additions & 0 deletions pkg/tools/clientmap/refcount.go
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
2 changes: 2 additions & 0 deletions pkg/tools/clientmap/refcount_test.go
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// Copyright (c) 2020 Doc.ai and/or its affiliates.
//
// Copyright (c) 2020 Cisco and/or its affiliates.
//
// SPDX-License-Identifier: Apache-2.0
Expand Down

0 comments on commit 603d83c

Please sign in to comment.