{"action":"created","issue":{"url":"https://api.github.com/repos/nodegit/nodegit/issues/827","labels_url":"https://api.github.com/repos/nodegit/nodegit/issues/827/labels{/name}","comments_url":"https://api.github.com/repos/nodegit/nodegit/issues/827/comments","events_url":"https://api.github.com/repos/nodegit/nodegit/issues/827/events","html_url":"https://github.com/nodegit/nodegit/issues/827","id":121736466,"number":827,"title":"Threading model","user":{"login":"joshaber","id":13760,"avatar_url":"https://avatars.githubusercontent.com/u/13760?v=3","gravatar_id":"","url":"https://api.github.com/users/joshaber","html_url":"https://github.com/joshaber","followers_url":"https://api.github.com/users/joshaber/followers","following_url":"https://api.github.com/users/joshaber/following{/other_user}","gists_url":"https://api.github.com/users/joshaber/gists{/gist_id}","starred_url":"https://api.github.com/users/joshaber/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/joshaber/subscriptions","organizations_url":"https://api.github.com/users/joshaber/orgs","repos_url":"https://api.github.com/users/joshaber/repos","events_url":"https://api.github.com/users/joshaber/events{/privacy}","received_events_url":"https://api.github.com/users/joshaber/received_events","type":"User","site_admin":true},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":4,"created_at":"2015-12-11T15:59:54Z","updated_at":"2015-12-11T18:12:15Z","closed_at":null,"body":":wave: \r\n\r\nI've been plumbing the depths of nodegit to understand how all the pieces fit together. I'm a bit concerned about the threading model.\r\n\r\nMy understanding:\r\n\r\n1. We enqueue asynchronous work with [`Nan::AsyncQueueWorker`](https://github.com/nodegit/nodegit/blob/c4292de4adb091c1fa7daed8515c105776714310/generate/templates/partials/async_function.cc#L77).\r\n2. `Nan::AsyncQueueWorker` calls [`uv_queue_work`](https://github.com/nodejs/nan/blob/367e82a60fbaa52716232cc89db1cc3f685d77d9/nan.h#L1702-L1709).\r\n3. `uv_queue_work` [enqueues the work on a threadpool](http://docs.libuv.org/en/v1.x/threadpool.html#c.uv_queue_work).\r\n\r\nThis means:\r\n\r\n1. We could do work on multiple threads at once.\r\n2. libgit2 says its objects [shouldn't be used across multiple threads at once](https://github.com/libgit2/libgit2/blob/6aa06b65cfcce164d7ad3ef184f40acb68406078/THREADING.md#sharing-objects).\r\n3. We could end up accessing the same objects across multiple threads at once, most often the repository object.\r\n4. Potential :boom:, definite violation of libgit2's threading model.\r\n\r\nIs my understanding correct? Am I missing something?"},"comment":{"url":"https://api.github.com/repos/nodegit/nodegit/issues/comments/164006949","html_url":"https://github.com/nodegit/nodegit/issues/827#issuecomment-164006949","issue_url":"https://api.github.com/repos/nodegit/nodegit/issues/827","id":164006949,"user":{"login":"johnhaley81","id":867780,"avatar_url":"https://avatars.githubusercontent.com/u/867780?v=3","gravatar_id":"","url":"https://api.github.com/users/johnhaley81","html_url":"https://github.com/johnhaley81","followers_url":"https://api.github.com/users/johnhaley81/followers","following_url":"https://api.github.com/users/johnhaley81/following{/other_user}","gists_url":"https://api.github.com/users/johnhaley81/gists{/gist_id}","starred_url":"https://api.github.com/users/johnhaley81/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnhaley81/subscriptions","organizations_url":"https://api.github.com/users/johnhaley81/orgs","repos_url":"https://api.github.com/users/johnhaley81/repos","events_url":"https://api.github.com/users/johnhaley81/events{/privacy}","received_events_url":"https://api.github.com/users/johnhaley81/received_events","type":"User","site_admin":false},"created_at":"2015-12-11T18:12:15Z","updated_at":"2015-12-11T18:12:15Z","body":"@tbranyen we're talking about this in gitter and I think you should join if you have the time :)"}}