{"action":"created","issue":{"url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/52","labels_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/52/labels{/name}","comments_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/52/comments","events_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/52/events","html_url":"https://github.com/ericsink/SQLitePCL.raw/issues/52","id":94187432,"number":52,"title":"Suggestion: Use double checking on locks","user":{"login":"CheloXL","id":201414,"avatar_url":"https://avatars.githubusercontent.com/u/201414?v=3","gravatar_id":"","url":"https://api.github.com/users/CheloXL","html_url":"https://github.com/CheloXL","followers_url":"https://api.github.com/users/CheloXL/followers","following_url":"https://api.github.com/users/CheloXL/following{/other_user}","gists_url":"https://api.github.com/users/CheloXL/gists{/gist_id}","starred_url":"https://api.github.com/users/CheloXL/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CheloXL/subscriptions","organizations_url":"https://api.github.com/users/CheloXL/orgs","repos_url":"https://api.github.com/users/CheloXL/repos","events_url":"https://api.github.com/users/CheloXL/events{/privacy}","received_events_url":"https://api.github.com/users/CheloXL/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":13,"created_at":"2015-07-10T01:09:38Z","updated_at":"2015-07-10T19:37:51Z","closed_at":null,"body":"You have several locks before accessing dictionaries. That's a lot of contention. I would replace that in all methods by a double checking (one check outside the lock, another inside).\r\n\r\nLike for example:\r\n\r\n```C#\r\ninternal static info getOrCreateFor(IntPtr db)\r\n{\r\n\tinfo i;\r\n\tif (_hooks_by_db.TryGetValue(db, out i))\r\n\t{\r\n\t\treturn i;\r\n\t}\r\n\r\n\tlock (_hooks_by_db)\r\n\t{\r\n\t\tif (_hooks_by_db.TryGetValue(db, out i))\r\n\t\t{\r\n\t\t\treturn i;\r\n\t\t}\r\n\r\n\t\treturn _hooks_by_db[db] = new info();\r\n\t}\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/comments/120503945","html_url":"https://github.com/ericsink/SQLitePCL.raw/issues/52#issuecomment-120503945","issue_url":"https://api.github.com/repos/ericsink/SQLitePCL.raw/issues/52","id":120503945,"user":{"login":"bordoley","id":2886153,"avatar_url":"https://avatars.githubusercontent.com/u/2886153?v=3","gravatar_id":"","url":"https://api.github.com/users/bordoley","html_url":"https://github.com/bordoley","followers_url":"https://api.github.com/users/bordoley/followers","following_url":"https://api.github.com/users/bordoley/following{/other_user}","gists_url":"https://api.github.com/users/bordoley/gists{/gist_id}","starred_url":"https://api.github.com/users/bordoley/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bordoley/subscriptions","organizations_url":"https://api.github.com/users/bordoley/orgs","repos_url":"https://api.github.com/users/bordoley/repos","events_url":"https://api.github.com/users/bordoley/events{/privacy}","received_events_url":"https://api.github.com/users/bordoley/received_events","type":"User","site_admin":false},"created_at":"2015-07-10T19:37:51Z","updated_at":"2015-07-10T19:37:51Z","body":"fallback to locking dictionary for .net4 :/"}}