{"action":"created","issue":{"url":"https://api.github.com/repos/CoderLuna/redbox/issues/2","labels_url":"https://api.github.com/repos/CoderLuna/redbox/issues/2/labels{/name}","comments_url":"https://api.github.com/repos/CoderLuna/redbox/issues/2/comments","events_url":"https://api.github.com/repos/CoderLuna/redbox/issues/2/events","html_url":"https://github.com/CoderLuna/redbox/issues/2","id":130663941,"number":2,"title":"states] 외부 transition 문제 발견","user":{"login":"CoderLuna","id":4078527,"avatar_url":"https://avatars.githubusercontent.com/u/4078527?v=3","gravatar_id":"","url":"https://api.github.com/users/CoderLuna","html_url":"https://github.com/CoderLuna","followers_url":"https://api.github.com/users/CoderLuna/followers","following_url":"https://api.github.com/users/CoderLuna/following{/other_user}","gists_url":"https://api.github.com/users/CoderLuna/gists{/gist_id}","starred_url":"https://api.github.com/users/CoderLuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoderLuna/subscriptions","organizations_url":"https://api.github.com/users/CoderLuna/orgs","repos_url":"https://api.github.com/users/CoderLuna/repos","events_url":"https://api.github.com/users/CoderLuna/events{/privacy}","received_events_url":"https://api.github.com/users/CoderLuna/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/CoderLuna/redbox/labels/question","name":"question","color":"e11d21"}],"state":"open","locked":false,"assignee":null,"milestone":{"url":"https://api.github.com/repos/CoderLuna/redbox/milestones/1","html_url":"https://github.com/CoderLuna/redbox/milestones/0.0.1","labels_url":"https://api.github.com/repos/CoderLuna/redbox/milestones/1/labels","id":1553611,"number":1,"title":"0.0.1","description":"## 개발 목표\r\n기본적으로 사용될 기본 라이브러리 및 Wrapper 라이브러리를 추가.\r\n\r\n## 기능 리스트\r\n- logging: 라이브러리에서 발생하는 메세지를 통합 관리\r\n- nscripts: 여러가지 embedding이 가능한 script를 wrapper로 쉽게 사용\r\n- states: finite-state machine을 구현하고 관리","creator":{"login":"CoderLuna","id":4078527,"avatar_url":"https://avatars.githubusercontent.com/u/4078527?v=3","gravatar_id":"","url":"https://api.github.com/users/CoderLuna","html_url":"https://github.com/CoderLuna","followers_url":"https://api.github.com/users/CoderLuna/followers","following_url":"https://api.github.com/users/CoderLuna/following{/other_user}","gists_url":"https://api.github.com/users/CoderLuna/gists{/gist_id}","starred_url":"https://api.github.com/users/CoderLuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoderLuna/subscriptions","organizations_url":"https://api.github.com/users/CoderLuna/orgs","repos_url":"https://api.github.com/users/CoderLuna/repos","events_url":"https://api.github.com/users/CoderLuna/events{/privacy}","received_events_url":"https://api.github.com/users/CoderLuna/received_events","type":"User","site_admin":false},"open_issues":1,"closed_issues":1,"state":"open","created_at":"2016-01-31T11:16:44Z","updated_at":"2016-02-02T12:16:07Z","due_on":"2016-04-29T15:00:00Z","closed_at":null},"comments":1,"created_at":"2016-02-02T12:10:36Z","updated_at":"2016-02-02T13:19:02Z","closed_at":null,"body":"내부에서 일어나는 transition에 대해서는 문제가 없지만 외부에서 transition을 일으킬 때 문제가 되는 상태가 발견되었다. 문제가 되는 코드는 다음과 같다.\r\n\r\n```cpp\r\nclass state_a : public state\r\n{\r\n\tstate* next()\r\n\t{\r\n\t\tif(time > now)\r\n\t\t\treturn next_state;\r\n\t\t\t\r\n\t\treturn nullptr;\r\n\t}\r\n};\r\n\r\nstate.new_state<state_a>();\r\nstate.new_state<state_b>();\r\n\r\nstate.transition<state_a>();\r\n```\r\n\r\n위와 같은 코드로 셋팅되어진 상태머신이 있고 `state_a` 상태에서 대기중인 경우에 `state.trainsition<state_b>();`가 호출 될 때 대기 중임에도 불구하고 `state_b`로 강제로 전환이 일어난다.\r\n\r\n물론 그런 동작이 정상인 경우도 있지만 아닌 경우에 대해서 대처할 방법이 필요하다."},"comment":{"url":"https://api.github.com/repos/CoderLuna/redbox/issues/comments/178571548","html_url":"https://github.com/CoderLuna/redbox/issues/2#issuecomment-178571548","issue_url":"https://api.github.com/repos/CoderLuna/redbox/issues/2","id":178571548,"user":{"login":"CoderLuna","id":4078527,"avatar_url":"https://avatars.githubusercontent.com/u/4078527?v=3","gravatar_id":"","url":"https://api.github.com/users/CoderLuna","html_url":"https://github.com/CoderLuna","followers_url":"https://api.github.com/users/CoderLuna/followers","following_url":"https://api.github.com/users/CoderLuna/following{/other_user}","gists_url":"https://api.github.com/users/CoderLuna/gists{/gist_id}","starred_url":"https://api.github.com/users/CoderLuna/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/CoderLuna/subscriptions","organizations_url":"https://api.github.com/users/CoderLuna/orgs","repos_url":"https://api.github.com/users/CoderLuna/repos","events_url":"https://api.github.com/users/CoderLuna/events{/privacy}","received_events_url":"https://api.github.com/users/CoderLuna/received_events","type":"User","site_admin":false},"created_at":"2016-02-02T13:19:02Z","updated_at":"2016-02-02T13:19:02Z","body":"해결 방안으로 `state_transition_block` 클레스를 상속받는 방법으로 특정 상태일 때 외부에서 transiton을 block 하는 방법으로 해당 문제를 피해나간다.\r\n\r\n```cpp\r\nclass state_a : public state_transition_block\r\n{\r\n};\r\n\r\nstate.tranition<state_b>();\r\n```\r\n이런 코드일 경우에 `state_b`로 transition이 일어나지 않는다.\r\n\r\n- 장점: 상속받는 것만으로 해당 설정을 할 수 있다.\r\n- 단점: 상속관계가 쓸대없이 복잡해질 우려가 있다.\r\n\r\n다른 방법이 있는지 좀 더 탐색이 필요할 것 같다."}}