{"action":"created","comment":{"url":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/comments/78295519","id":78295519,"diff_hunk":"@@ -781,12 +830,32 @@ private enum State\n \t\t\tNoMoreData,\n \t\t}\n \n+\t    public async Task WaitDoneReadingAsync(CancellationToken cancellationToken=default(CancellationToken))\n+\t    {\n+\t        cancellationToken.ThrowIfCancellationRequested();\n+\t        await m_done_reading.WaitAsync(cancellationToken).ConfigureAwait(false);\n+\t        m_done_reading.Release();\n+\t    }\n+\n \t\tstatic readonly Task<bool> s_falseTask = Task.FromResult(false);\n \t\tstatic readonly Task<bool> s_trueTask = Task.FromResult(true);\n \n \t\tMySqlCommand m_command;\n \t\tMySqlSession m_session;\n-\t\tState m_state;\n+\t    SemaphoreSlim m_done_reading = new SemaphoreSlim(1);","path":"src/MySqlConnector/MySqlClient/MySqlDataReader.cs","position":119,"original_position":119,"commit_id":"eb6cd6ebf56d662d2cba36d617f415d6c8226f85","original_commit_id":"eb6cd6ebf56d662d2cba36d617f415d6c8226f85","user":{"login":"bgrainger","id":188129,"avatar_url":"https://avatars.githubusercontent.com/u/188129?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrainger","html_url":"https://github.com/bgrainger","followers_url":"https://api.github.com/users/bgrainger/followers","following_url":"https://api.github.com/users/bgrainger/following{/other_user}","gists_url":"https://api.github.com/users/bgrainger/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrainger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrainger/subscriptions","organizations_url":"https://api.github.com/users/bgrainger/orgs","repos_url":"https://api.github.com/users/bgrainger/repos","events_url":"https://api.github.com/users/bgrainger/events{/privacy}","received_events_url":"https://api.github.com/users/bgrainger/received_events","type":"User","site_admin":false},"body":"If this semaphore starts with an initial count of 1, then the first call to `WaitAsync` will enter the semaphore immediately; thus this won't actually enforce mutual exclusion.\r\n\r\nI'm also not sure that this would correctly handle the case of multiple threads calling `ExecuteAsync` and all waiting on the semaphore.","created_at":"2016-09-11T13:44:40Z","updated_at":"2016-09-11T13:44:40Z","html_url":"https://github.com/bgrainger/MySqlConnector/pull/50#discussion_r78295519","pull_request_url":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50","_links":{"self":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/comments/78295519"},"html":{"href":"https://github.com/bgrainger/MySqlConnector/pull/50#discussion_r78295519"},"pull_request":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50"}}},"pull_request":{"url":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50","id":84703268,"html_url":"https://github.com/bgrainger/MySqlConnector/pull/50","diff_url":"https://github.com/bgrainger/MySqlConnector/pull/50.diff","patch_url":"https://github.com/bgrainger/MySqlConnector/pull/50.patch","issue_url":"https://api.github.com/repos/bgrainger/MySqlConnector/issues/50","number":50,"state":"open","locked":false,"title":"json type; bool casting; async reader waiting","user":{"login":"caleblloyd","id":2414837,"avatar_url":"https://avatars.githubusercontent.com/u/2414837?v=3","gravatar_id":"","url":"https://api.github.com/users/caleblloyd","html_url":"https://github.com/caleblloyd","followers_url":"https://api.github.com/users/caleblloyd/followers","following_url":"https://api.github.com/users/caleblloyd/following{/other_user}","gists_url":"https://api.github.com/users/caleblloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/caleblloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caleblloyd/subscriptions","organizations_url":"https://api.github.com/users/caleblloyd/orgs","repos_url":"https://api.github.com/users/caleblloyd/repos","events_url":"https://api.github.com/users/caleblloyd/events{/privacy}","received_events_url":"https://api.github.com/users/caleblloyd/received_events","type":"User","site_admin":false},"body":"We're getting closer!  Here's the 3 things that I have added:\r\n\r\n**JSON Support**\r\n\r\nNeeded a way to cast byte[] from GetValue into a JsonObject[T] in Pomelo's library.  Since JsonObject[T] may be passed as JsonObject[string], JsonObject[Dictionary[string,string]], or other types, a simple cast did not work.  Solution was to use reflection to cast to these types.  Now any object that implements an implicit method for byte[] can deserialize JSON.  Here's Pomelo's proposed implementation:\r\n\r\n    public static implicit operator JsonObject<T>(byte[] serialized)\r\n    {\r\n        return new JsonObject<T>\r\n        {\r\n            Json = Text.Encoding.UTF8.GetString(serialized)\r\n        };\r\n    }\r\n\r\n**Boolean Casting**\r\n\r\nAdded logic to cast integer types stored in the DBMS to booleans if requested.\r\n\r\n**Asynchronous Wait for Reader to Complete**\r\n\r\nMySQL only supports one active reader at a time.  If multiple asynchronous queries are sent at once in the same Database Context, this can cause multiple statements to execute at once that try to open readers.\r\n\r\nI needed a way to asynchronously wait on a reader to complete so that I could serialize these operations.  The solution I am proposing uses a semaphore that is locked until the reader is complete, then unlocked.  I'm open for suggestions on other ways to achieve this, but this was the only way I could come up with that didn't involve polling.","created_at":"2016-09-09T19:13:58Z","updated_at":"2016-09-11T13:44:40Z","closed_at":null,"merged_at":null,"merge_commit_sha":"74b9ce21b0749f47e95615a0dcea771b2300048b","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50/commits","review_comments_url":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50/comments","review_comment_url":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bgrainger/MySqlConnector/issues/50/comments","statuses_url":"https://api.github.com/repos/bgrainger/MySqlConnector/statuses/eb6cd6ebf56d662d2cba36d617f415d6c8226f85","head":{"label":"caleblloyd:master","ref":"master","sha":"eb6cd6ebf56d662d2cba36d617f415d6c8226f85","user":{"login":"caleblloyd","id":2414837,"avatar_url":"https://avatars.githubusercontent.com/u/2414837?v=3","gravatar_id":"","url":"https://api.github.com/users/caleblloyd","html_url":"https://github.com/caleblloyd","followers_url":"https://api.github.com/users/caleblloyd/followers","following_url":"https://api.github.com/users/caleblloyd/following{/other_user}","gists_url":"https://api.github.com/users/caleblloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/caleblloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caleblloyd/subscriptions","organizations_url":"https://api.github.com/users/caleblloyd/orgs","repos_url":"https://api.github.com/users/caleblloyd/repos","events_url":"https://api.github.com/users/caleblloyd/events{/privacy}","received_events_url":"https://api.github.com/users/caleblloyd/received_events","type":"User","site_admin":false},"repo":{"id":67824910,"name":"MySqlConnector","full_name":"caleblloyd/MySqlConnector","owner":{"login":"caleblloyd","id":2414837,"avatar_url":"https://avatars.githubusercontent.com/u/2414837?v=3","gravatar_id":"","url":"https://api.github.com/users/caleblloyd","html_url":"https://github.com/caleblloyd","followers_url":"https://api.github.com/users/caleblloyd/followers","following_url":"https://api.github.com/users/caleblloyd/following{/other_user}","gists_url":"https://api.github.com/users/caleblloyd/gists{/gist_id}","starred_url":"https://api.github.com/users/caleblloyd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/caleblloyd/subscriptions","organizations_url":"https://api.github.com/users/caleblloyd/orgs","repos_url":"https://api.github.com/users/caleblloyd/repos","events_url":"https://api.github.com/users/caleblloyd/events{/privacy}","received_events_url":"https://api.github.com/users/caleblloyd/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/caleblloyd/MySqlConnector","description":"Async MySql.Data replacement for .NET Core","fork":true,"url":"https://api.github.com/repos/caleblloyd/MySqlConnector","forks_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/forks","keys_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/teams","hooks_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/hooks","issue_events_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/issues/events{/number}","events_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/events","assignees_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/assignees{/user}","branches_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/branches{/branch}","tags_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/tags","blobs_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/git/refs{/sha}","trees_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/statuses/{sha}","languages_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/languages","stargazers_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/stargazers","contributors_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/contributors","subscribers_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/subscribers","subscription_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/subscription","commits_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/commits{/sha}","git_commits_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/git/commits{/sha}","comments_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/comments{/number}","issue_comment_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/issues/comments{/number}","contents_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/contents/{+path}","compare_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/merges","archive_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/downloads","issues_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/issues{/number}","pulls_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/pulls{/number}","milestones_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/milestones{/number}","notifications_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/labels{/name}","releases_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/releases{/id}","deployments_url":"https://api.github.com/repos/caleblloyd/MySqlConnector/deployments","created_at":"2016-09-09T19:03:06Z","updated_at":"2016-09-09T19:03:07Z","pushed_at":"2016-09-09T19:03:59Z","git_url":"git://github.com/caleblloyd/MySqlConnector.git","ssh_url":"git@github.com:caleblloyd/MySqlConnector.git","clone_url":"https://github.com/caleblloyd/MySqlConnector.git","svn_url":"https://github.com/caleblloyd/MySqlConnector","homepage":null,"size":287,"stargazers_count":0,"watchers_count":0,"language":"C#","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"bgrainger:master","ref":"master","sha":"c0ce5a53ade8e9b2e776e8a60253cb1c2f773bf6","user":{"login":"bgrainger","id":188129,"avatar_url":"https://avatars.githubusercontent.com/u/188129?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrainger","html_url":"https://github.com/bgrainger","followers_url":"https://api.github.com/users/bgrainger/followers","following_url":"https://api.github.com/users/bgrainger/following{/other_user}","gists_url":"https://api.github.com/users/bgrainger/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrainger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrainger/subscriptions","organizations_url":"https://api.github.com/users/bgrainger/orgs","repos_url":"https://api.github.com/users/bgrainger/repos","events_url":"https://api.github.com/users/bgrainger/events{/privacy}","received_events_url":"https://api.github.com/users/bgrainger/received_events","type":"User","site_admin":false},"repo":{"id":55185530,"name":"MySqlConnector","full_name":"bgrainger/MySqlConnector","owner":{"login":"bgrainger","id":188129,"avatar_url":"https://avatars.githubusercontent.com/u/188129?v=3","gravatar_id":"","url":"https://api.github.com/users/bgrainger","html_url":"https://github.com/bgrainger","followers_url":"https://api.github.com/users/bgrainger/followers","following_url":"https://api.github.com/users/bgrainger/following{/other_user}","gists_url":"https://api.github.com/users/bgrainger/gists{/gist_id}","starred_url":"https://api.github.com/users/bgrainger/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bgrainger/subscriptions","organizations_url":"https://api.github.com/users/bgrainger/orgs","repos_url":"https://api.github.com/users/bgrainger/repos","events_url":"https://api.github.com/users/bgrainger/events{/privacy}","received_events_url":"https://api.github.com/users/bgrainger/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bgrainger/MySqlConnector","description":"Async MySql.Data replacement for .NET Core","fork":false,"url":"https://api.github.com/repos/bgrainger/MySqlConnector","forks_url":"https://api.github.com/repos/bgrainger/MySqlConnector/forks","keys_url":"https://api.github.com/repos/bgrainger/MySqlConnector/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bgrainger/MySqlConnector/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bgrainger/MySqlConnector/teams","hooks_url":"https://api.github.com/repos/bgrainger/MySqlConnector/hooks","issue_events_url":"https://api.github.com/repos/bgrainger/MySqlConnector/issues/events{/number}","events_url":"https://api.github.com/repos/bgrainger/MySqlConnector/events","assignees_url":"https://api.github.com/repos/bgrainger/MySqlConnector/assignees{/user}","branches_url":"https://api.github.com/repos/bgrainger/MySqlConnector/branches{/branch}","tags_url":"https://api.github.com/repos/bgrainger/MySqlConnector/tags","blobs_url":"https://api.github.com/repos/bgrainger/MySqlConnector/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bgrainger/MySqlConnector/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bgrainger/MySqlConnector/git/refs{/sha}","trees_url":"https://api.github.com/repos/bgrainger/MySqlConnector/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bgrainger/MySqlConnector/statuses/{sha}","languages_url":"https://api.github.com/repos/bgrainger/MySqlConnector/languages","stargazers_url":"https://api.github.com/repos/bgrainger/MySqlConnector/stargazers","contributors_url":"https://api.github.com/repos/bgrainger/MySqlConnector/contributors","subscribers_url":"https://api.github.com/repos/bgrainger/MySqlConnector/subscribers","subscription_url":"https://api.github.com/repos/bgrainger/MySqlConnector/subscription","commits_url":"https://api.github.com/repos/bgrainger/MySqlConnector/commits{/sha}","git_commits_url":"https://api.github.com/repos/bgrainger/MySqlConnector/git/commits{/sha}","comments_url":"https://api.github.com/repos/bgrainger/MySqlConnector/comments{/number}","issue_comment_url":"https://api.github.com/repos/bgrainger/MySqlConnector/issues/comments{/number}","contents_url":"https://api.github.com/repos/bgrainger/MySqlConnector/contents/{+path}","compare_url":"https://api.github.com/repos/bgrainger/MySqlConnector/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bgrainger/MySqlConnector/merges","archive_url":"https://api.github.com/repos/bgrainger/MySqlConnector/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bgrainger/MySqlConnector/downloads","issues_url":"https://api.github.com/repos/bgrainger/MySqlConnector/issues{/number}","pulls_url":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls{/number}","milestones_url":"https://api.github.com/repos/bgrainger/MySqlConnector/milestones{/number}","notifications_url":"https://api.github.com/repos/bgrainger/MySqlConnector/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bgrainger/MySqlConnector/labels{/name}","releases_url":"https://api.github.com/repos/bgrainger/MySqlConnector/releases{/id}","deployments_url":"https://api.github.com/repos/bgrainger/MySqlConnector/deployments","created_at":"2016-03-31T21:54:37Z","updated_at":"2016-09-09T05:36:51Z","pushed_at":"2016-09-11T05:28:23Z","git_url":"git://github.com/bgrainger/MySqlConnector.git","ssh_url":"git@github.com:bgrainger/MySqlConnector.git","clone_url":"https://github.com/bgrainger/MySqlConnector.git","svn_url":"https://github.com/bgrainger/MySqlConnector","homepage":null,"size":358,"stargazers_count":86,"watchers_count":86,"language":"C#","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":16,"mirror_url":null,"open_issues_count":15,"forks":16,"open_issues":15,"watchers":86,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50"},"html":{"href":"https://github.com/bgrainger/MySqlConnector/pull/50"},"issue":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/issues/50"},"comments":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/issues/50/comments"},"review_comments":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50/comments"},"review_comment":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/pulls/50/commits"},"statuses":{"href":"https://api.github.com/repos/bgrainger/MySqlConnector/statuses/eb6cd6ebf56d662d2cba36d617f415d6c8226f85"}}}}
{"actor":{"display_login":"bgrainger"}}