GitHub PullRequestReviewCommentEvent at 2014-05-24 09:20:12
Repository: mozart2
Actor: sjrd
Payload: {"comment":{"url":"https://api.github.com/repos/mozart/mozart2/pulls/comments/13025516","id":13025516,"diff_hunk":"@@ -0,0 +1,317 @@\n+// Copyright © 2011, Université catholique de Louvain\n+// All rights reserved.\n+//\n+// Redistribution and use in source and binary forms, with or without\n+// modification, are permitted provided that the following conditions are met:\n+//\n+// *  Redistributions of source code must retain the above copyright notice,\n+//    this list of conditions and the following disclaimer.\n+// *  Redistributions in binary form must reproduce the above copyright notice,\n+//    this list of conditions and the following disclaimer in the documentation\n+//    and/or other materials provided with the distribution.\n+//\n+// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\"\n+// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE\n+// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE\n+// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE\n+// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR\n+// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF\n+// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS\n+// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN\n+// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)\n+// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE\n+// POSSIBILITY OF SUCH DAMAGE.\n+\n+#include \"boostenv.hh\"\n+\n+#include <exception>\n+#include <boost/bind.hpp>\n+#include <boost/random/random_device.hpp>\n+\n+namespace mozart { namespace boostenv {\n+\n+/////////////\n+// BoostVM //\n+/////////////\n+\n+BoostVM::BoostVM(BoostEnvironment& environment,\n+                 VMIdentifier identifier,\n+                 VirtualMachineOptions options,\n+                 const std::string& app, bool isURL) :\n+  VirtualMachine(environment, options), vm(this),\n+  env(environment), identifier(identifier),\n+  uuidGenerator(random_generator),\n+  _portClosed(false),\n+  _asyncIONodeCount(0),\n+  preemptionTimer(environment.io_service),\n+  alarmTimer(environment.io_service),\n+  _terminationRequested(false),\n+  _terminationStatus(0),\n+  _terminationReason(\"normal\") {\n+\n+  // Make sure the IO thread will wait for us\n+  _work = new boost::asio::io_service::work(environment.io_service);\n+\n+  builtins::biref::registerBuiltinModOS(vm);\n+  builtins::biref::registerBuiltinModVM(vm);\n+\n+  // Initialize the pseudo random number generator with a really random seed\n+  boost::random::random_device generator;\n+  random_generator.seed(generator);\n+\n+  UnstableNode future = ReadOnlyVariable::build(vm);\n+  _stream = _headOfStream = RichNode(future).getStableRef(vm);\n+\n+  // Finally start the VM thread, which will initialize and run the VM\n+  boost::thread thread(&BoostVM::start, this, app, isURL);\n+  thread.detach();\n+};\n+\n+void BoostVM::start(std::string app, bool isURL) {","path":"vm/boostenv/main/boostvm.cc","position":null,"original_position":70,"commit_id":"6491ffdc24a9bb6950b3d1164469a06648e88bf6","original_commit_id":"fee6193b82da1e80416db063d0ea3ee80ac73a75","user":{"login":"sjrd","id":535934,"avatar_url":"https://avatars.githubusercontent.com/u/535934?","gravatar_id":"bc554c7355c8476dd63375b314b1bd97","url":"https://api.github.com/users/sjrd","html_url":"https://github.com/sjrd","followers_url":"https://api.github.com/users/sjrd/followers","following_url":"https://api.github.com/users/sjrd/following{/other_user}","gists_url":"https://api.github.com/users/sjrd/gists{/gist_id}","starred_url":"https://api.github.com/users/sjrd/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sjrd/subscriptions","organizations_url":"https://api.github.com/users/sjrd/orgs","repos_url":"https://api.github.com/users/sjrd/repos","events_url":"https://api.github.com/users/sjrd/events{/privacy}","received_events_url":"https://api.github.com/users/sjrd/received_events","type":"User","site_admin":false},"body":"It would be better to allocate that string on the (c++) heap, and pass pointers, ideally an `std::unique_ptr`. Not only to be able to delete it asap, but I would be more confident that there are indeed no thread-safety issues.","created_at":"2014-05-24T09:20:12Z","updated_at":"2014-05-24T09:20:12Z","html_url":"https://github.com/mozart/mozart2/pull/173#discussion_r13025516","pull_request_url":"https://api.github.com/repos/mozart/mozart2/pulls/173","_links":{"self":{"href":"https://api.github.com/repos/mozart/mozart2/pulls/comments/13025516"},"html":{"href":"https://github.com/mozart/mozart2/pull/173#discussion_r13025516"},"pull_request":{"href":"https://api.github.com/repos/mozart/mozart2/pulls/173"}}}}