{"action":"created","comment":{"url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/comments/35018906","id":35018906,"diff_hunk":"@@ -0,0 +1,209 @@\n+{-# LANGUAGE OverloadedStrings #-}\n+{-# LANGUAGE TemplateHaskell #-}\n+\n+module FuncTorrent.ControlThread where\n+\n+import Control.Concurrent\n+import GHC.Conc\n+import Control.Lens\n+import Data.IORef\n+import Control.Monad hiding (\n+    forM , forM_ , mapM , mapM_ , msum , sequence , sequence_ )\n+\n+import FuncTorrent.Tracker (TrackerResponse(..), tracker, mkTrackerResponse, peers)\n+import FuncTorrent.Bencode (decode)\n+import FuncTorrent.Metainfo (Metainfo(..))\n+\n+import FuncTorrent.Peer\n+import FuncTorrent.PeerThread\n+import FuncTorrent.PeerThreadData\n+\n+data ControlThread = ControlThread {\n+        _metaInfo           :: Metainfo\n+    ,   _trackerResponses   :: [TrackerResponse]\n+    ,   _peerList           :: [Peer]\n+    ,   _peerThreads        :: [(PeerThread, ThreadId)]\n+--    ,   _diskIO_Handle   :: Handle\n+    ,   _controlTStatus     :: IORef ControlThreadStatus\n+    ,   _controlTAction     :: IORef ControlThreadAction\n+    }\n+\n+data ControlThreadStatus =\n+        Stopped\n+    |   Downloading\n+    |   Seeding\n+  deriving (Eq, Show)","path":"src/FuncTorrent/ControlThread.hs","position":35,"original_position":35,"commit_id":"304b685cd134684a62912eae1af47a001d9860d8","original_commit_id":"304b685cd134684a62912eae1af47a001d9860d8","user":{"login":"jaseemabid","id":601714,"avatar_url":"https://avatars.githubusercontent.com/u/601714?v=3","gravatar_id":"","url":"https://api.github.com/users/jaseemabid","html_url":"https://github.com/jaseemabid","followers_url":"https://api.github.com/users/jaseemabid/followers","following_url":"https://api.github.com/users/jaseemabid/following{/other_user}","gists_url":"https://api.github.com/users/jaseemabid/gists{/gist_id}","starred_url":"https://api.github.com/users/jaseemabid/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jaseemabid/subscriptions","organizations_url":"https://api.github.com/users/jaseemabid/orgs","repos_url":"https://api.github.com/users/jaseemabid/repos","events_url":"https://api.github.com/users/jaseemabid/events{/privacy}","received_events_url":"https://api.github.com/users/jaseemabid/received_events","type":"User","site_admin":false},"body":"Any particular reason for `deriving (Eq, Show)` ? Same question about `ControlThreadAction`","created_at":"2015-07-20T17:15:21Z","updated_at":"2015-07-20T17:15:21Z","html_url":"https://github.com/bangalore-haskell-user-group/functorrent/pull/36#discussion_r35018906","pull_request_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36","_links":{"self":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/comments/35018906"},"html":{"href":"https://github.com/bangalore-haskell-user-group/functorrent/pull/36#discussion_r35018906"},"pull_request":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36"}}},"pull_request":{"url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36","id":39286609,"html_url":"https://github.com/bangalore-haskell-user-group/functorrent/pull/36","diff_url":"https://github.com/bangalore-haskell-user-group/functorrent/pull/36.diff","patch_url":"https://github.com/bangalore-haskell-user-group/functorrent/pull/36.patch","issue_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/issues/36","number":36,"state":"open","locked":false,"title":"Thread related code commit","user":{"login":"dfordivam","id":681060,"avatar_url":"https://avatars.githubusercontent.com/u/681060?v=3","gravatar_id":"","url":"https://api.github.com/users/dfordivam","html_url":"https://github.com/dfordivam","followers_url":"https://api.github.com/users/dfordivam/followers","following_url":"https://api.github.com/users/dfordivam/following{/other_user}","gists_url":"https://api.github.com/users/dfordivam/gists{/gist_id}","starred_url":"https://api.github.com/users/dfordivam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfordivam/subscriptions","organizations_url":"https://api.github.com/users/dfordivam/orgs","repos_url":"https://api.github.com/users/dfordivam/repos","events_url":"https://api.github.com/users/dfordivam/events{/privacy}","received_events_url":"https://api.github.com/users/dfordivam/received_events","type":"User","site_admin":false},"body":"This is a big commit which implements three major parts of torrent application \r\n1. Server thread\r\n2. Control thread - For each torrent\r\n3. Peer thread - For each peer communication\r\n\r\nCurrently these threads are just forked based on the tracker response. They dont do anything inside them. on Ctrl-C all these threads exit gracefully and torrent client stops.","created_at":"2015-07-06T16:38:19Z","updated_at":"2015-07-20T17:15:21Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7695b58816568561c8550110ba0dde3f5b19d3f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36/commits","review_comments_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36/comments","review_comment_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/comments{/number}","comments_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/issues/36/comments","statuses_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/statuses/304b685cd134684a62912eae1af47a001d9860d8","head":{"label":"dfordivam:server-design","ref":"server-design","sha":"304b685cd134684a62912eae1af47a001d9860d8","user":{"login":"dfordivam","id":681060,"avatar_url":"https://avatars.githubusercontent.com/u/681060?v=3","gravatar_id":"","url":"https://api.github.com/users/dfordivam","html_url":"https://github.com/dfordivam","followers_url":"https://api.github.com/users/dfordivam/followers","following_url":"https://api.github.com/users/dfordivam/following{/other_user}","gists_url":"https://api.github.com/users/dfordivam/gists{/gist_id}","starred_url":"https://api.github.com/users/dfordivam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfordivam/subscriptions","organizations_url":"https://api.github.com/users/dfordivam/orgs","repos_url":"https://api.github.com/users/dfordivam/repos","events_url":"https://api.github.com/users/dfordivam/events{/privacy}","received_events_url":"https://api.github.com/users/dfordivam/received_events","type":"User","site_admin":false},"repo":{"id":31133947,"name":"functorrent","full_name":"dfordivam/functorrent","owner":{"login":"dfordivam","id":681060,"avatar_url":"https://avatars.githubusercontent.com/u/681060?v=3","gravatar_id":"","url":"https://api.github.com/users/dfordivam","html_url":"https://github.com/dfordivam","followers_url":"https://api.github.com/users/dfordivam/followers","following_url":"https://api.github.com/users/dfordivam/following{/other_user}","gists_url":"https://api.github.com/users/dfordivam/gists{/gist_id}","starred_url":"https://api.github.com/users/dfordivam/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dfordivam/subscriptions","organizations_url":"https://api.github.com/users/dfordivam/orgs","repos_url":"https://api.github.com/users/dfordivam/repos","events_url":"https://api.github.com/users/dfordivam/events{/privacy}","received_events_url":"https://api.github.com/users/dfordivam/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dfordivam/functorrent","description":"A bit torrent client","fork":true,"url":"https://api.github.com/repos/dfordivam/functorrent","forks_url":"https://api.github.com/repos/dfordivam/functorrent/forks","keys_url":"https://api.github.com/repos/dfordivam/functorrent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dfordivam/functorrent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dfordivam/functorrent/teams","hooks_url":"https://api.github.com/repos/dfordivam/functorrent/hooks","issue_events_url":"https://api.github.com/repos/dfordivam/functorrent/issues/events{/number}","events_url":"https://api.github.com/repos/dfordivam/functorrent/events","assignees_url":"https://api.github.com/repos/dfordivam/functorrent/assignees{/user}","branches_url":"https://api.github.com/repos/dfordivam/functorrent/branches{/branch}","tags_url":"https://api.github.com/repos/dfordivam/functorrent/tags","blobs_url":"https://api.github.com/repos/dfordivam/functorrent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dfordivam/functorrent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dfordivam/functorrent/git/refs{/sha}","trees_url":"https://api.github.com/repos/dfordivam/functorrent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dfordivam/functorrent/statuses/{sha}","languages_url":"https://api.github.com/repos/dfordivam/functorrent/languages","stargazers_url":"https://api.github.com/repos/dfordivam/functorrent/stargazers","contributors_url":"https://api.github.com/repos/dfordivam/functorrent/contributors","subscribers_url":"https://api.github.com/repos/dfordivam/functorrent/subscribers","subscription_url":"https://api.github.com/repos/dfordivam/functorrent/subscription","commits_url":"https://api.github.com/repos/dfordivam/functorrent/commits{/sha}","git_commits_url":"https://api.github.com/repos/dfordivam/functorrent/git/commits{/sha}","comments_url":"https://api.github.com/repos/dfordivam/functorrent/comments{/number}","issue_comment_url":"https://api.github.com/repos/dfordivam/functorrent/issues/comments{/number}","contents_url":"https://api.github.com/repos/dfordivam/functorrent/contents/{+path}","compare_url":"https://api.github.com/repos/dfordivam/functorrent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dfordivam/functorrent/merges","archive_url":"https://api.github.com/repos/dfordivam/functorrent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dfordivam/functorrent/downloads","issues_url":"https://api.github.com/repos/dfordivam/functorrent/issues{/number}","pulls_url":"https://api.github.com/repos/dfordivam/functorrent/pulls{/number}","milestones_url":"https://api.github.com/repos/dfordivam/functorrent/milestones{/number}","notifications_url":"https://api.github.com/repos/dfordivam/functorrent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dfordivam/functorrent/labels{/name}","releases_url":"https://api.github.com/repos/dfordivam/functorrent/releases{/id}","created_at":"2015-02-21T17:38:32Z","updated_at":"2015-03-01T15:16:06Z","pushed_at":"2015-07-10T15:01:46Z","git_url":"git://github.com/dfordivam/functorrent.git","ssh_url":"git@github.com:dfordivam/functorrent.git","clone_url":"https://github.com/dfordivam/functorrent.git","svn_url":"https://github.com/dfordivam/functorrent","homepage":null,"size":444,"stargazers_count":0,"watchers_count":0,"language":"Haskell","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":"bangalore-haskell-user-group:master","ref":"master","sha":"053bed92a152ca115b9da8c8ab0c799407c65b14","user":{"login":"bangalore-haskell-user-group","id":12463682,"avatar_url":"https://avatars.githubusercontent.com/u/12463682?v=3","gravatar_id":"","url":"https://api.github.com/users/bangalore-haskell-user-group","html_url":"https://github.com/bangalore-haskell-user-group","followers_url":"https://api.github.com/users/bangalore-haskell-user-group/followers","following_url":"https://api.github.com/users/bangalore-haskell-user-group/following{/other_user}","gists_url":"https://api.github.com/users/bangalore-haskell-user-group/gists{/gist_id}","starred_url":"https://api.github.com/users/bangalore-haskell-user-group/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangalore-haskell-user-group/subscriptions","organizations_url":"https://api.github.com/users/bangalore-haskell-user-group/orgs","repos_url":"https://api.github.com/users/bangalore-haskell-user-group/repos","events_url":"https://api.github.com/users/bangalore-haskell-user-group/events{/privacy}","received_events_url":"https://api.github.com/users/bangalore-haskell-user-group/received_events","type":"Organization","site_admin":false},"repo":{"id":30867288,"name":"functorrent","full_name":"bangalore-haskell-user-group/functorrent","owner":{"login":"bangalore-haskell-user-group","id":12463682,"avatar_url":"https://avatars.githubusercontent.com/u/12463682?v=3","gravatar_id":"","url":"https://api.github.com/users/bangalore-haskell-user-group","html_url":"https://github.com/bangalore-haskell-user-group","followers_url":"https://api.github.com/users/bangalore-haskell-user-group/followers","following_url":"https://api.github.com/users/bangalore-haskell-user-group/following{/other_user}","gists_url":"https://api.github.com/users/bangalore-haskell-user-group/gists{/gist_id}","starred_url":"https://api.github.com/users/bangalore-haskell-user-group/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bangalore-haskell-user-group/subscriptions","organizations_url":"https://api.github.com/users/bangalore-haskell-user-group/orgs","repos_url":"https://api.github.com/users/bangalore-haskell-user-group/repos","events_url":"https://api.github.com/users/bangalore-haskell-user-group/events{/privacy}","received_events_url":"https://api.github.com/users/bangalore-haskell-user-group/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/bangalore-haskell-user-group/functorrent","description":"A bit torrent client","fork":false,"url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent","forks_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/forks","keys_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/teams","hooks_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/hooks","issue_events_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/issues/events{/number}","events_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/events","assignees_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/assignees{/user}","branches_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/branches{/branch}","tags_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/tags","blobs_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/git/refs{/sha}","trees_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/statuses/{sha}","languages_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/languages","stargazers_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/stargazers","contributors_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/contributors","subscribers_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/subscribers","subscription_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/subscription","commits_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/commits{/sha}","git_commits_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/git/commits{/sha}","comments_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/comments{/number}","issue_comment_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/issues/comments{/number}","contents_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/contents/{+path}","compare_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/merges","archive_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/downloads","issues_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/issues{/number}","pulls_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls{/number}","milestones_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/milestones{/number}","notifications_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/labels{/name}","releases_url":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/releases{/id}","created_at":"2015-02-16T12:27:03Z","updated_at":"2015-07-11T10:00:45Z","pushed_at":"2015-07-06T16:38:19Z","git_url":"git://github.com/bangalore-haskell-user-group/functorrent.git","ssh_url":"git@github.com:bangalore-haskell-user-group/functorrent.git","clone_url":"https://github.com/bangalore-haskell-user-group/functorrent.git","svn_url":"https://github.com/bangalore-haskell-user-group/functorrent","homepage":null,"size":628,"stargazers_count":9,"watchers_count":9,"language":"Haskell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":9,"mirror_url":null,"open_issues_count":10,"forks":9,"open_issues":10,"watchers":9,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36"},"html":{"href":"https://github.com/bangalore-haskell-user-group/functorrent/pull/36"},"issue":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/issues/36"},"comments":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/issues/36/comments"},"review_comments":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36/comments"},"review_comment":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/pulls/36/commits"},"statuses":{"href":"https://api.github.com/repos/bangalore-haskell-user-group/functorrent/statuses/304b685cd134684a62912eae1af47a001d9860d8"}}}}