{"action":"created","issue":{"url":"https://api.github.com/repos/streamrail/concurrent-map/issues/18","repository_url":"https://api.github.com/repos/streamrail/concurrent-map","labels_url":"https://api.github.com/repos/streamrail/concurrent-map/issues/18/labels{/name}","comments_url":"https://api.github.com/repos/streamrail/concurrent-map/issues/18/comments","events_url":"https://api.github.com/repos/streamrail/concurrent-map/issues/18/events","html_url":"https://github.com/streamrail/concurrent-map/issues/18","id":145969148,"number":18,"title":"Usage for counters","user":{"login":"stgleb","id":5112367,"avatar_url":"https://avatars.githubusercontent.com/u/5112367?v=3","gravatar_id":"","url":"https://api.github.com/users/stgleb","html_url":"https://github.com/stgleb","followers_url":"https://api.github.com/users/stgleb/followers","following_url":"https://api.github.com/users/stgleb/following{/other_user}","gists_url":"https://api.github.com/users/stgleb/gists{/gist_id}","starred_url":"https://api.github.com/users/stgleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stgleb/subscriptions","organizations_url":"https://api.github.com/users/stgleb/orgs","repos_url":"https://api.github.com/users/stgleb/repos","events_url":"https://api.github.com/users/stgleb/events{/privacy}","received_events_url":"https://api.github.com/users/stgleb/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-04-05T12:12:30Z","updated_at":"2016-04-05T12:16:09Z","closed_at":null,"body":"Hi, folks.\r\n\r\nI've decided to use your CHM implemendation. But i have specifical use case. I use\r\nmap for counting, actually freqeuency of words. So you guarantee synchronization of each particular\r\noperation. How can i reach consistency when i\r\n\r\n1) read value from map\r\n2) increment it\r\n3) write it back to map\r\n\r\nOf source i can use my own global lock, but it will totaly destoys idea of map concurrency.\r\nShoud i take ConcurrentShard and use it internal RWLock?"},"comment":{"url":"https://api.github.com/repos/streamrail/concurrent-map/issues/comments/205773478","html_url":"https://github.com/streamrail/concurrent-map/issues/18#issuecomment-205773478","issue_url":"https://api.github.com/repos/streamrail/concurrent-map/issues/18","id":205773478,"user":{"login":"stgleb","id":5112367,"avatar_url":"https://avatars.githubusercontent.com/u/5112367?v=3","gravatar_id":"","url":"https://api.github.com/users/stgleb","html_url":"https://github.com/stgleb","followers_url":"https://api.github.com/users/stgleb/followers","following_url":"https://api.github.com/users/stgleb/following{/other_user}","gists_url":"https://api.github.com/users/stgleb/gists{/gist_id}","starred_url":"https://api.github.com/users/stgleb/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stgleb/subscriptions","organizations_url":"https://api.github.com/users/stgleb/orgs","repos_url":"https://api.github.com/users/stgleb/repos","events_url":"https://api.github.com/users/stgleb/events{/privacy}","received_events_url":"https://api.github.com/users/stgleb/received_events","type":"User","site_admin":false},"created_at":"2016-04-05T12:16:09Z","updated_at":"2016-04-05T12:16:09Z","body":"i've used such code \r\n\r\n`\tfor i := 0; i < len(words); i++ {\r\n\t\tshard := wordsMap.GetShard(words[i])\r\n\t\tshard.RWMutex.Lock()\r\n\t\tcount, ok := wordsMap.Get(words[i])\r\n\t\t\r\n\t\tif ok != true {\r\n\t\t\tcount = 0\r\n\t\t} else {\r\n\t\t\tcount += 1\r\n\t\t}\r\n\t\twordsMap.Set(words[i], count)\r\n\t\tshard.RWMutex.Unlock()\r\n\t}`"}}