{"action":"created","comment":{"url":"https://api.github.com/repos/lsst/qserv/pulls/comments/41805892","id":41805892,"diff_hunk":"@@ -50,68 +50,93 @@\n #define LSST_QSERV_WCONTROL_FOREMAN_H\n \n // System headers\n+#include <atomic>\n #include <memory>\n \n+// LSST headers\n+#include \"lsst/log/Log.h\"\n+\n // Local headers\n #include \"wbase/Base.h\"\n+#include \"wbase/MsgProcessor.h\"\n #include \"wbase/Task.h\"\n \n // Forward declarations\n namespace lsst {\n namespace qserv {\n-namespace wbase {\n-    class MsgProcessor;\n-}}} // End of forward declarations\n+namespace wdb {\n+\tclass ChunkResourceMgr;\n+}\n+}}\n \n namespace lsst {\n namespace qserv {\n namespace wcontrol {\n \n-/// Foreman is a pooling thread manager that is pluggable with different\n-/// scheduling objects\n-class Foreman {\n+class RunnerMgr;\n+\n+/// An abstract interface. Runners receive a reference to an\n+/// object implementing this and make calls to report start and\n+/// finish events for tasks they run. Schedulers must return\n+/// TaskWatcher objects so that runners can make reports.\n+class TaskWatcher {\n public:\n-    typedef std::shared_ptr<Foreman> Ptr;\n-\n-    /// An abstract interface. Runners receive a reference to an\n-    /// object implementing this and make calls to report start and\n-    /// finish events for tasks they run. Schedulers must return\n-    /// TaskWatcher objects so that runners can make reports.\n-    class TaskWatcher {\n-    public:\n-        virtual ~TaskWatcher() {}\n-        virtual void markStarted(wbase::Task::Ptr t) {}\n-        virtual void markFinished(wbase::Task::Ptr t) {}\n-    };\n-\n-    /// An abstract scheduler interface. Foreman objects use Scheduler instances\n-    /// to determine what tasks to launch upon triggering events.\n-    class Scheduler : public TaskWatcher {\n-    public:\n-        typedef std::shared_ptr<Scheduler> Ptr;\n-        virtual ~Scheduler() {}\n-\n-        virtual bool removeByHash(std::string const& hash) { return false; }\n-        virtual void queueTaskAct(wbase::Task::Ptr incoming) = 0;\n-        virtual wbase::TaskQueuePtr nopAct(wbase::TaskQueuePtr running) = 0;\n-        virtual wbase::TaskQueuePtr newTaskAct(wbase::Task::Ptr incoming,\n-                                               wbase::TaskQueuePtr running) = 0;\n-        virtual wbase::TaskQueuePtr taskFinishAct(wbase::Task::Ptr finished,\n-                                                  wbase::TaskQueuePtr running) = 0;\n-    };\n-\n-    virtual bool squashByHash(std::string const& hash) { return false; }\n-\n-    virtual std::shared_ptr<wbase::MsgProcessor> getProcessor() = 0;\n-    virtual ~Foreman() {}\n+    virtual ~TaskWatcher() {}\n+    virtual void markStarted(wbase::Task::Ptr t) {}\n+    virtual void markFinished(wbase::Task::Ptr t) {}\n+};\n \n-protected:\n-    explicit Foreman() {}\n+/// An abstract scheduler interface. Foreman objects use Scheduler instances\n+/// to determine what tasks to launch upon triggering events.\n+class Scheduler : public TaskWatcher, public wbase::TaskScheduler {\n+public:\n+\tusing Ptr = std::shared_ptr<Scheduler>;\n+    virtual ~Scheduler() {}\n+\n+    virtual bool removeByHash(std::string const& hash) { return false; }\n+\n+    /// Take appropriate action when a task in the Schedule is cancelled. Doing\n+    /// nothing should be harmless, but some Schedulers may work better if cancelled\n+    /// tasks are removed.\n+    virtual void taskCancelled(wbase::Task *task) { return; }\n+    virtual void queueTaskAct(wbase::Task::Ptr incoming) = 0;\n+    virtual wbase::TaskQueuePtr nopAct(wbase::TaskQueuePtr running) = 0;\n+    virtual wbase::TaskQueuePtr newTaskAct(wbase::Task::Ptr incoming,\n+                                           wbase::TaskQueuePtr running) = 0;\n+    virtual wbase::TaskQueuePtr taskFinishAct(wbase::Task::Ptr finished,\n+                                              wbase::TaskQueuePtr running) = 0;\n };\n \n-/// Factory function for Foreman that hooks in a scheduler\n-Foreman::Ptr\n-newForeman(Foreman::Scheduler::Ptr s);\n+/// Foreman is a pooling thread manager that is pluggable with different scheduling objects.\n+///\n+class Foreman : public wbase::MsgProcessor{\n+public:\n+\tusing Ptr = std::shared_ptr<Foreman>;\n+\tstatic Foreman::Ptr newForeman(Scheduler::Ptr const& s);\n+    Foreman(Scheduler::Ptr s);","path":"core/modules/wcontrol/Foreman.h","position":111,"original_position":111,"commit_id":"eadf22996a7ef5b224488c77094ec625cb95cd9c","original_commit_id":"eadf22996a7ef5b224488c77094ec625cb95cd9c","user":{"login":"andy-slac","id":4266950,"avatar_url":"https://avatars.githubusercontent.com/u/4266950?v=3","gravatar_id":"","url":"https://api.github.com/users/andy-slac","html_url":"https://github.com/andy-slac","followers_url":"https://api.github.com/users/andy-slac/followers","following_url":"https://api.github.com/users/andy-slac/following{/other_user}","gists_url":"https://api.github.com/users/andy-slac/gists{/gist_id}","starred_url":"https://api.github.com/users/andy-slac/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/andy-slac/subscriptions","organizations_url":"https://api.github.com/users/andy-slac/orgs","repos_url":"https://api.github.com/users/andy-slac/repos","events_url":"https://api.github.com/users/andy-slac/events{/privacy}","received_events_url":"https://api.github.com/users/andy-slac/received_events","type":"User","site_admin":false},"body":"`const&`?","created_at":"2015-10-12T21:58:55Z","updated_at":"2015-10-12T21:58:55Z","html_url":"https://github.com/lsst/qserv/pull/141#discussion_r41805892","pull_request_url":"https://api.github.com/repos/lsst/qserv/pulls/141","_links":{"self":{"href":"https://api.github.com/repos/lsst/qserv/pulls/comments/41805892"},"html":{"href":"https://github.com/lsst/qserv/pull/141#discussion_r41805892"},"pull_request":{"href":"https://api.github.com/repos/lsst/qserv/pulls/141"}}},"pull_request":{"url":"https://api.github.com/repos/lsst/qserv/pulls/141","id":47456816,"html_url":"https://github.com/lsst/qserv/pull/141","diff_url":"https://github.com/lsst/qserv/pull/141.diff","patch_url":"https://github.com/lsst/qserv/pull/141.patch","issue_url":"https://api.github.com/repos/lsst/qserv/issues/141","number":141,"state":"open","locked":false,"title":"Tickets/dm 3946","user":{"login":"jgates108","id":6558057,"avatar_url":"https://avatars.githubusercontent.com/u/6558057?v=3","gravatar_id":"","url":"https://api.github.com/users/jgates108","html_url":"https://github.com/jgates108","followers_url":"https://api.github.com/users/jgates108/followers","following_url":"https://api.github.com/users/jgates108/following{/other_user}","gists_url":"https://api.github.com/users/jgates108/gists{/gist_id}","starred_url":"https://api.github.com/users/jgates108/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/jgates108/subscriptions","organizations_url":"https://api.github.com/users/jgates108/orgs","repos_url":"https://api.github.com/users/jgates108/repos","events_url":"https://api.github.com/users/jgates108/events{/privacy}","received_events_url":"https://api.github.com/users/jgates108/received_events","type":"User","site_admin":false},"body":"","created_at":"2015-10-12T19:42:42Z","updated_at":"2015-10-12T21:58:55Z","closed_at":null,"merged_at":null,"merge_commit_sha":"438e9f5fa000cee842fbc933cbc4989598d64306","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/lsst/qserv/pulls/141/commits","review_comments_url":"https://api.github.com/repos/lsst/qserv/pulls/141/comments","review_comment_url":"https://api.github.com/repos/lsst/qserv/pulls/comments{/number}","comments_url":"https://api.github.com/repos/lsst/qserv/issues/141/comments","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/eadf22996a7ef5b224488c77094ec625cb95cd9c","head":{"label":"lsst:tickets/DM-3946","ref":"tickets/DM-3946","sha":"eadf22996a7ef5b224488c77094ec625cb95cd9c","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013460,"name":"qserv","full_name":"lsst/qserv","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/qserv","description":"LSST Query Services","fork":false,"url":"https://api.github.com/repos/lsst/qserv","forks_url":"https://api.github.com/repos/lsst/qserv/forks","keys_url":"https://api.github.com/repos/lsst/qserv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/qserv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/qserv/teams","hooks_url":"https://api.github.com/repos/lsst/qserv/hooks","issue_events_url":"https://api.github.com/repos/lsst/qserv/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/qserv/events","assignees_url":"https://api.github.com/repos/lsst/qserv/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/qserv/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/qserv/tags","blobs_url":"https://api.github.com/repos/lsst/qserv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/qserv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/qserv/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/qserv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/qserv/languages","stargazers_url":"https://api.github.com/repos/lsst/qserv/stargazers","contributors_url":"https://api.github.com/repos/lsst/qserv/contributors","subscribers_url":"https://api.github.com/repos/lsst/qserv/subscribers","subscription_url":"https://api.github.com/repos/lsst/qserv/subscription","commits_url":"https://api.github.com/repos/lsst/qserv/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/qserv/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/qserv/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/qserv/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/qserv/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/qserv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/qserv/merges","archive_url":"https://api.github.com/repos/lsst/qserv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/qserv/downloads","issues_url":"https://api.github.com/repos/lsst/qserv/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/qserv/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/qserv/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/qserv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/qserv/labels{/name}","releases_url":"https://api.github.com/repos/lsst/qserv/releases{/id}","created_at":"2014-08-16T07:50:36Z","updated_at":"2015-05-08T02:01:15Z","pushed_at":"2015-10-12T20:16:54Z","git_url":"git://github.com/lsst/qserv.git","ssh_url":"git@github.com:lsst/qserv.git","clone_url":"https://github.com/lsst/qserv.git","svn_url":"https://github.com/lsst/qserv","homepage":"http://dm.lsst.org/","size":21396,"stargazers_count":4,"watchers_count":4,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":4,"default_branch":"master"}},"base":{"label":"lsst:master","ref":"master","sha":"2be6e48fb53c075aab729bbc3b2e94e09de8b47e","user":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"repo":{"id":23013460,"name":"qserv","full_name":"lsst/qserv","owner":{"login":"lsst","id":1134504,"avatar_url":"https://avatars.githubusercontent.com/u/1134504?v=3","gravatar_id":"","url":"https://api.github.com/users/lsst","html_url":"https://github.com/lsst","followers_url":"https://api.github.com/users/lsst/followers","following_url":"https://api.github.com/users/lsst/following{/other_user}","gists_url":"https://api.github.com/users/lsst/gists{/gist_id}","starred_url":"https://api.github.com/users/lsst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/lsst/subscriptions","organizations_url":"https://api.github.com/users/lsst/orgs","repos_url":"https://api.github.com/users/lsst/repos","events_url":"https://api.github.com/users/lsst/events{/privacy}","received_events_url":"https://api.github.com/users/lsst/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/lsst/qserv","description":"LSST Query Services","fork":false,"url":"https://api.github.com/repos/lsst/qserv","forks_url":"https://api.github.com/repos/lsst/qserv/forks","keys_url":"https://api.github.com/repos/lsst/qserv/keys{/key_id}","collaborators_url":"https://api.github.com/repos/lsst/qserv/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/lsst/qserv/teams","hooks_url":"https://api.github.com/repos/lsst/qserv/hooks","issue_events_url":"https://api.github.com/repos/lsst/qserv/issues/events{/number}","events_url":"https://api.github.com/repos/lsst/qserv/events","assignees_url":"https://api.github.com/repos/lsst/qserv/assignees{/user}","branches_url":"https://api.github.com/repos/lsst/qserv/branches{/branch}","tags_url":"https://api.github.com/repos/lsst/qserv/tags","blobs_url":"https://api.github.com/repos/lsst/qserv/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/lsst/qserv/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/lsst/qserv/git/refs{/sha}","trees_url":"https://api.github.com/repos/lsst/qserv/git/trees{/sha}","statuses_url":"https://api.github.com/repos/lsst/qserv/statuses/{sha}","languages_url":"https://api.github.com/repos/lsst/qserv/languages","stargazers_url":"https://api.github.com/repos/lsst/qserv/stargazers","contributors_url":"https://api.github.com/repos/lsst/qserv/contributors","subscribers_url":"https://api.github.com/repos/lsst/qserv/subscribers","subscription_url":"https://api.github.com/repos/lsst/qserv/subscription","commits_url":"https://api.github.com/repos/lsst/qserv/commits{/sha}","git_commits_url":"https://api.github.com/repos/lsst/qserv/git/commits{/sha}","comments_url":"https://api.github.com/repos/lsst/qserv/comments{/number}","issue_comment_url":"https://api.github.com/repos/lsst/qserv/issues/comments{/number}","contents_url":"https://api.github.com/repos/lsst/qserv/contents/{+path}","compare_url":"https://api.github.com/repos/lsst/qserv/compare/{base}...{head}","merges_url":"https://api.github.com/repos/lsst/qserv/merges","archive_url":"https://api.github.com/repos/lsst/qserv/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/lsst/qserv/downloads","issues_url":"https://api.github.com/repos/lsst/qserv/issues{/number}","pulls_url":"https://api.github.com/repos/lsst/qserv/pulls{/number}","milestones_url":"https://api.github.com/repos/lsst/qserv/milestones{/number}","notifications_url":"https://api.github.com/repos/lsst/qserv/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/lsst/qserv/labels{/name}","releases_url":"https://api.github.com/repos/lsst/qserv/releases{/id}","created_at":"2014-08-16T07:50:36Z","updated_at":"2015-05-08T02:01:15Z","pushed_at":"2015-10-12T20:16:54Z","git_url":"git://github.com/lsst/qserv.git","ssh_url":"git@github.com:lsst/qserv.git","clone_url":"https://github.com/lsst/qserv.git","svn_url":"https://github.com/lsst/qserv","homepage":"http://dm.lsst.org/","size":21396,"stargazers_count":4,"watchers_count":4,"language":"C++","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4,"mirror_url":null,"open_issues_count":4,"forks":4,"open_issues":4,"watchers":4,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/lsst/qserv/pulls/141"},"html":{"href":"https://github.com/lsst/qserv/pull/141"},"issue":{"href":"https://api.github.com/repos/lsst/qserv/issues/141"},"comments":{"href":"https://api.github.com/repos/lsst/qserv/issues/141/comments"},"review_comments":{"href":"https://api.github.com/repos/lsst/qserv/pulls/141/comments"},"review_comment":{"href":"https://api.github.com/repos/lsst/qserv/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/lsst/qserv/pulls/141/commits"},"statuses":{"href":"https://api.github.com/repos/lsst/qserv/statuses/eadf22996a7ef5b224488c77094ec625cb95cd9c"}}}}