{"action":"created","comment":{"url":"https://api.github.com/repos/Raphine/Raph_Library/pulls/comments/81481430","pull_request_review_id":2458746,"id":81481430,"diff_hunk":"@@ -16,37 +16,114 @@\n  * along with this program; if not, write to the Free Software\n  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.\n  *\n- * Author: Liva\n+ * Author: Liva, hikalium\n  * \n  */\n \n #ifndef __RAPH_LIB_CPU_H__\n #define __RAPH_LIB_CPU_H__\n+enum class CpuPurpose {\n+  kNone = 0,\n+  kLowPriority,\n+  kGeneralPurpose,\n+  kHighPerformance,\n+  kCpuPurposesNum\n+};\n+\n+class CpuId {\n+  private:\n+    int rawid;\n+    void Init(int newid){\n+      rawid = newid;\n+    }\n+  public:\n+    static const int kCpuIdNotFound = -1;\n+    static const int kCpuIdBootProcessor = 0;\n+    CpuId(){\n+      Init(kCpuIdNotFound);\n+    }\n+    CpuId(int newid){\n+      Init(newid);\n+    }\n+    int GetRawId(){\n+      return rawid;\n+    }\n+    uint8_t GetApicId();\n+    bool IsValid();\n+};\n \n class CpuCtrlInterface {\n-public:\n-  virtual ~CpuCtrlInterface() {\n-  }\n-  virtual volatile int GetId() = 0;\n-  virtual int GetHowManyCpus() = 0;\n-  bool IsValidId(int cpuid) {\n-    return (cpuid >= 0 && cpuid < GetHowManyCpus());\n-  }\n+  public:\n+    const int kCpuIdNotFound = -1;\n+    const int kCpuIdBootProcessor = 0;\n+    //\n+    virtual ~CpuCtrlInterface() {\n+    }\n+    virtual CpuId GetCpuId() = 0;\n+    virtual int GetHowManyCpus() = 0;\n+    virtual CpuId RetainCpuIdForPurpose(CpuPurpose p) = 0;\n+    virtual void ReleaseCpuId(CpuId cpuid) = 0;\n+    virtual void AssignCpusNotAssignedToGeneralPurpose() = 0;\n };\n \n #ifdef __KERNEL__\n-#include <apic.h>\n #include <global.h>\n \n class CpuCtrl : public CpuCtrlInterface {\n-public:\n-  virtual volatile int GetId() override {\n-    return apic_ctrl->GetCpuId();\n-  }\n-  virtual int GetHowManyCpus() override {\n-    return apic_ctrl->GetHowManyCpus();\n-  }\n+  public:\n+    CpuCtrl() {\n+      cpu_purpose_map[0] = CpuPurpose::kLowPriority;\n+    }\n+    CpuId GetCpuId() override;\n+    int GetHowManyCpus() override;\n+    CpuId RetainCpuIdForPurpose(CpuPurpose p) override; \n+    void ReleaseCpuId(CpuId cpuid) override {\n+      int raw_cpu_id = cpuid.GetRawId();\n+      if(cpu_purpose_count[raw_cpu_id] > 0) cpu_purpose_count[raw_cpu_id]--;\n+      if(cpu_purpose_count[raw_cpu_id] == 0){\n+        cpu_purpose_map[raw_cpu_id] = CpuPurpose::kNone;\n+      }\n+    }\n+    void AssignCpusNotAssignedToGeneralPurpose(){","path":"rlib/cpu.h","position":89,"original_position":89,"commit_id":"1d33c95ef450fc39ed29a0a67ce2ce9d26d2525e","original_commit_id":"1d33c95ef450fc39ed29a0a67ce2ce9d26d2525e","user":{"login":"liva","id":536883,"avatar_url":"https://avatars.githubusercontent.com/u/536883?v=3","gravatar_id":"","url":"https://api.github.com/users/liva","html_url":"https://github.com/liva","followers_url":"https://api.github.com/users/liva/followers","following_url":"https://api.github.com/users/liva/following{/other_user}","gists_url":"https://api.github.com/users/liva/gists{/gist_id}","starred_url":"https://api.github.com/users/liva/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/liva/subscriptions","organizations_url":"https://api.github.com/users/liva/orgs","repos_url":"https://api.github.com/users/liva/repos","events_url":"https://api.github.com/users/liva/events{/privacy}","received_events_url":"https://api.github.com/users/liva/received_events","type":"User","site_admin":false},"body":"中括弧の前にスペース欲しいです→コーディング規約","created_at":"2016-10-03T00:09:37Z","updated_at":"2016-10-03T00:13:34Z","html_url":"https://github.com/Raphine/Raph_Library/pull/78#discussion_r81481430","pull_request_url":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78","_links":{"self":{"href":"https://api.github.com/repos/Raphine/Raph_Library/pulls/comments/81481430"},"html":{"href":"https://github.com/Raphine/Raph_Library/pull/78#discussion_r81481430"},"pull_request":{"href":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78"}}},"pull_request":{"url":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78","id":84691542,"html_url":"https://github.com/Raphine/Raph_Library/pull/78","diff_url":"https://github.com/Raphine/Raph_Library/pull/78.diff","patch_url":"https://github.com/Raphine/Raph_Library/pull/78.patch","issue_url":"https://api.github.com/repos/Raphine/Raph_Library/issues/78","number":78,"state":"open","locked":false,"title":"Impl cpu.h [contains side effect]","user":{"login":"hikalium","id":10512779,"avatar_url":"https://avatars.githubusercontent.com/u/10512779?v=3","gravatar_id":"","url":"https://api.github.com/users/hikalium","html_url":"https://github.com/hikalium","followers_url":"https://api.github.com/users/hikalium/followers","following_url":"https://api.github.com/users/hikalium/following{/other_user}","gists_url":"https://api.github.com/users/hikalium/gists{/gist_id}","starred_url":"https://api.github.com/users/hikalium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikalium/subscriptions","organizations_url":"https://api.github.com/users/hikalium/orgs","repos_url":"https://api.github.com/users/hikalium/repos","events_url":"https://api.github.com/users/hikalium/events{/privacy}","received_events_url":"https://api.github.com/users/hikalium/received_events","type":"User","site_admin":false},"body":"## Expected side effects: \r\n- There is no method `GetId()` and `IsValidId()` anymore.\r\n - use `GetCpuId()` and `IsValidCpuId()` instead.","created_at":"2016-09-09T17:55:04Z","updated_at":"2016-10-03T00:13:34Z","closed_at":null,"merged_at":null,"merge_commit_sha":"979dcbd5a9ca80cbd90f08d44eeb59be82a6de27","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78/commits","review_comments_url":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78/comments","review_comment_url":"https://api.github.com/repos/Raphine/Raph_Library/pulls/comments{/number}","comments_url":"https://api.github.com/repos/Raphine/Raph_Library/issues/78/comments","statuses_url":"https://api.github.com/repos/Raphine/Raph_Library/statuses/1d33c95ef450fc39ed29a0a67ce2ce9d26d2525e","head":{"label":"hikalium:cpuctrl","ref":"cpuctrl","sha":"1d33c95ef450fc39ed29a0a67ce2ce9d26d2525e","user":{"login":"hikalium","id":10512779,"avatar_url":"https://avatars.githubusercontent.com/u/10512779?v=3","gravatar_id":"","url":"https://api.github.com/users/hikalium","html_url":"https://github.com/hikalium","followers_url":"https://api.github.com/users/hikalium/followers","following_url":"https://api.github.com/users/hikalium/following{/other_user}","gists_url":"https://api.github.com/users/hikalium/gists{/gist_id}","starred_url":"https://api.github.com/users/hikalium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikalium/subscriptions","organizations_url":"https://api.github.com/users/hikalium/orgs","repos_url":"https://api.github.com/users/hikalium/repos","events_url":"https://api.github.com/users/hikalium/events{/privacy}","received_events_url":"https://api.github.com/users/hikalium/received_events","type":"User","site_admin":false},"repo":{"id":67297032,"name":"Raph_Library","full_name":"hikalium/Raph_Library","owner":{"login":"hikalium","id":10512779,"avatar_url":"https://avatars.githubusercontent.com/u/10512779?v=3","gravatar_id":"","url":"https://api.github.com/users/hikalium","html_url":"https://github.com/hikalium","followers_url":"https://api.github.com/users/hikalium/followers","following_url":"https://api.github.com/users/hikalium/following{/other_user}","gists_url":"https://api.github.com/users/hikalium/gists{/gist_id}","starred_url":"https://api.github.com/users/hikalium/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/hikalium/subscriptions","organizations_url":"https://api.github.com/users/hikalium/orgs","repos_url":"https://api.github.com/users/hikalium/repos","events_url":"https://api.github.com/users/hikalium/events{/privacy}","received_events_url":"https://api.github.com/users/hikalium/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/hikalium/Raph_Library","description":null,"fork":true,"url":"https://api.github.com/repos/hikalium/Raph_Library","forks_url":"https://api.github.com/repos/hikalium/Raph_Library/forks","keys_url":"https://api.github.com/repos/hikalium/Raph_Library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/hikalium/Raph_Library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/hikalium/Raph_Library/teams","hooks_url":"https://api.github.com/repos/hikalium/Raph_Library/hooks","issue_events_url":"https://api.github.com/repos/hikalium/Raph_Library/issues/events{/number}","events_url":"https://api.github.com/repos/hikalium/Raph_Library/events","assignees_url":"https://api.github.com/repos/hikalium/Raph_Library/assignees{/user}","branches_url":"https://api.github.com/repos/hikalium/Raph_Library/branches{/branch}","tags_url":"https://api.github.com/repos/hikalium/Raph_Library/tags","blobs_url":"https://api.github.com/repos/hikalium/Raph_Library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/hikalium/Raph_Library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/hikalium/Raph_Library/git/refs{/sha}","trees_url":"https://api.github.com/repos/hikalium/Raph_Library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/hikalium/Raph_Library/statuses/{sha}","languages_url":"https://api.github.com/repos/hikalium/Raph_Library/languages","stargazers_url":"https://api.github.com/repos/hikalium/Raph_Library/stargazers","contributors_url":"https://api.github.com/repos/hikalium/Raph_Library/contributors","subscribers_url":"https://api.github.com/repos/hikalium/Raph_Library/subscribers","subscription_url":"https://api.github.com/repos/hikalium/Raph_Library/subscription","commits_url":"https://api.github.com/repos/hikalium/Raph_Library/commits{/sha}","git_commits_url":"https://api.github.com/repos/hikalium/Raph_Library/git/commits{/sha}","comments_url":"https://api.github.com/repos/hikalium/Raph_Library/comments{/number}","issue_comment_url":"https://api.github.com/repos/hikalium/Raph_Library/issues/comments{/number}","contents_url":"https://api.github.com/repos/hikalium/Raph_Library/contents/{+path}","compare_url":"https://api.github.com/repos/hikalium/Raph_Library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/hikalium/Raph_Library/merges","archive_url":"https://api.github.com/repos/hikalium/Raph_Library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/hikalium/Raph_Library/downloads","issues_url":"https://api.github.com/repos/hikalium/Raph_Library/issues{/number}","pulls_url":"https://api.github.com/repos/hikalium/Raph_Library/pulls{/number}","milestones_url":"https://api.github.com/repos/hikalium/Raph_Library/milestones{/number}","notifications_url":"https://api.github.com/repos/hikalium/Raph_Library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/hikalium/Raph_Library/labels{/name}","releases_url":"https://api.github.com/repos/hikalium/Raph_Library/releases{/id}","deployments_url":"https://api.github.com/repos/hikalium/Raph_Library/deployments","created_at":"2016-09-03T15:24:11Z","updated_at":"2016-09-03T15:24:12Z","pushed_at":"2016-10-02T13:55:45Z","git_url":"git://github.com/hikalium/Raph_Library.git","ssh_url":"git@github.com:hikalium/Raph_Library.git","clone_url":"https://github.com/hikalium/Raph_Library.git","svn_url":"https://github.com/hikalium/Raph_Library","homepage":null,"size":123,"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":"Raphine:kernel","ref":"kernel","sha":"7a11518bfe7d55c8998988743c6fb2a4e6cb6f27","user":{"login":"Raphine","id":18119103,"avatar_url":"https://avatars.githubusercontent.com/u/18119103?v=3","gravatar_id":"","url":"https://api.github.com/users/Raphine","html_url":"https://github.com/Raphine","followers_url":"https://api.github.com/users/Raphine/followers","following_url":"https://api.github.com/users/Raphine/following{/other_user}","gists_url":"https://api.github.com/users/Raphine/gists{/gist_id}","starred_url":"https://api.github.com/users/Raphine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Raphine/subscriptions","organizations_url":"https://api.github.com/users/Raphine/orgs","repos_url":"https://api.github.com/users/Raphine/repos","events_url":"https://api.github.com/users/Raphine/events{/privacy}","received_events_url":"https://api.github.com/users/Raphine/received_events","type":"Organization","site_admin":false},"repo":{"id":58621534,"name":"Raph_Library","full_name":"Raphine/Raph_Library","owner":{"login":"Raphine","id":18119103,"avatar_url":"https://avatars.githubusercontent.com/u/18119103?v=3","gravatar_id":"","url":"https://api.github.com/users/Raphine","html_url":"https://github.com/Raphine","followers_url":"https://api.github.com/users/Raphine/followers","following_url":"https://api.github.com/users/Raphine/following{/other_user}","gists_url":"https://api.github.com/users/Raphine/gists{/gist_id}","starred_url":"https://api.github.com/users/Raphine/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/Raphine/subscriptions","organizations_url":"https://api.github.com/users/Raphine/orgs","repos_url":"https://api.github.com/users/Raphine/repos","events_url":"https://api.github.com/users/Raphine/events{/privacy}","received_events_url":"https://api.github.com/users/Raphine/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/Raphine/Raph_Library","description":"","fork":false,"url":"https://api.github.com/repos/Raphine/Raph_Library","forks_url":"https://api.github.com/repos/Raphine/Raph_Library/forks","keys_url":"https://api.github.com/repos/Raphine/Raph_Library/keys{/key_id}","collaborators_url":"https://api.github.com/repos/Raphine/Raph_Library/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/Raphine/Raph_Library/teams","hooks_url":"https://api.github.com/repos/Raphine/Raph_Library/hooks","issue_events_url":"https://api.github.com/repos/Raphine/Raph_Library/issues/events{/number}","events_url":"https://api.github.com/repos/Raphine/Raph_Library/events","assignees_url":"https://api.github.com/repos/Raphine/Raph_Library/assignees{/user}","branches_url":"https://api.github.com/repos/Raphine/Raph_Library/branches{/branch}","tags_url":"https://api.github.com/repos/Raphine/Raph_Library/tags","blobs_url":"https://api.github.com/repos/Raphine/Raph_Library/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/Raphine/Raph_Library/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/Raphine/Raph_Library/git/refs{/sha}","trees_url":"https://api.github.com/repos/Raphine/Raph_Library/git/trees{/sha}","statuses_url":"https://api.github.com/repos/Raphine/Raph_Library/statuses/{sha}","languages_url":"https://api.github.com/repos/Raphine/Raph_Library/languages","stargazers_url":"https://api.github.com/repos/Raphine/Raph_Library/stargazers","contributors_url":"https://api.github.com/repos/Raphine/Raph_Library/contributors","subscribers_url":"https://api.github.com/repos/Raphine/Raph_Library/subscribers","subscription_url":"https://api.github.com/repos/Raphine/Raph_Library/subscription","commits_url":"https://api.github.com/repos/Raphine/Raph_Library/commits{/sha}","git_commits_url":"https://api.github.com/repos/Raphine/Raph_Library/git/commits{/sha}","comments_url":"https://api.github.com/repos/Raphine/Raph_Library/comments{/number}","issue_comment_url":"https://api.github.com/repos/Raphine/Raph_Library/issues/comments{/number}","contents_url":"https://api.github.com/repos/Raphine/Raph_Library/contents/{+path}","compare_url":"https://api.github.com/repos/Raphine/Raph_Library/compare/{base}...{head}","merges_url":"https://api.github.com/repos/Raphine/Raph_Library/merges","archive_url":"https://api.github.com/repos/Raphine/Raph_Library/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/Raphine/Raph_Library/downloads","issues_url":"https://api.github.com/repos/Raphine/Raph_Library/issues{/number}","pulls_url":"https://api.github.com/repos/Raphine/Raph_Library/pulls{/number}","milestones_url":"https://api.github.com/repos/Raphine/Raph_Library/milestones{/number}","notifications_url":"https://api.github.com/repos/Raphine/Raph_Library/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/Raphine/Raph_Library/labels{/name}","releases_url":"https://api.github.com/repos/Raphine/Raph_Library/releases{/id}","deployments_url":"https://api.github.com/repos/Raphine/Raph_Library/deployments","created_at":"2016-05-12T08:11:31Z","updated_at":"2016-05-29T04:30:14Z","pushed_at":"2016-10-02T13:55:46Z","git_url":"git://github.com/Raphine/Raph_Library.git","ssh_url":"git@github.com:Raphine/Raph_Library.git","clone_url":"https://github.com/Raphine/Raph_Library.git","svn_url":"https://github.com/Raphine/Raph_Library","homepage":null,"size":143,"stargazers_count":1,"watchers_count":1,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":2,"mirror_url":null,"open_issues_count":8,"forks":2,"open_issues":8,"watchers":1,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78"},"html":{"href":"https://github.com/Raphine/Raph_Library/pull/78"},"issue":{"href":"https://api.github.com/repos/Raphine/Raph_Library/issues/78"},"comments":{"href":"https://api.github.com/repos/Raphine/Raph_Library/issues/78/comments"},"review_comments":{"href":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78/comments"},"review_comment":{"href":"https://api.github.com/repos/Raphine/Raph_Library/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/Raphine/Raph_Library/pulls/78/commits"},"statuses":{"href":"https://api.github.com/repos/Raphine/Raph_Library/statuses/1d33c95ef450fc39ed29a0a67ce2ce9d26d2525e"}}}}
{"actor":{"display_login":"liva"}}