{"action":"created","comment":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/39921477","id":39921477,"diff_hunk":"@@ -0,0 +1,653 @@\n+module std.experimental.perpetual;\n+/** TODO: \n+ *\t\tdocumentation\n+ *\t\tversion(Windows) impl\n+ */\n+\n+private import std.exception;\n+private import std.conv : to, emplace;\n+private import std.file : exists;\n+private import std.traits : hasIndirections, isCallable, isAssignable, isArray;\n+\n+/**\n+ * Creates an object mapped to a file. The object is persistent \n+ *   and outlives the parent application. The file may be reopened\n+ *   and the object reused, it's value persists. This might be viewed\n+ *   as kind of binary serialization with the difference that access\n+ *   to the variable is almost as fast as any regular memory. The \n+ *   structure might be also used as memory shared between processes/threads,\n+ *   however, no built-in synchronization is provided.\n+ *\n+ * If the template parameter T is immutable, the created object is also\n+ *   immutable. Note: shared memory is then created in read-only\n+ *   mode, so even cast to mutable and attempt to modify it will cause\n+ *   segmentation fault.\n+ *\n+ * The Perpetual(T) exists in two forms. When T is regular value type\n+ *   (including static arrays), Persistent(T) behaves like reference to\n+ *   the object. In the second form, Persistent(T[]), the class behaves\n+ *   as proxy to dynamic array providing slicing interface. Note, even\n+ *   in this case, elements of the array must be value type, no pointers\n+ *   nor references to process's memory allowed.\n+ *\n+ * The values created are initialized with std.conv.emplace using\n+ *  additional arguments if any. The object remains in valid state\n+ *  until the file is deleted or modified.\n+ **/\n+struct Perpetual(T)\n+{\n+\t// underlying shared memory allocator\n+\tprivate ShMem _heap;\n+\tprivate enum _tag=\"Perpetual!(\"~T.stringof~\")\";\n+\n+\t//dynamic array\n+\tstatic if(is(T == Element[],Element))\n+\t{\n+\t\tprivate Element[] _value;\n+\t\tprivate enum bool dynamic=true;\n+\t\tstatic assert(!hasIndirections!Element\n+\t\t    , Element.stringof~\" is reference type\");\n+\n+\t\t/** Proxy to underlying dynamic array type.\n+\t\t *  Forwards calls to opSlice(), length() etc\n+\t\t */\n+\t\t@property Element[] Ref() { return _value; }\n+\n+\t\t/// Convert to string the value, not the class itself\n+\t\t@property toString() { return to!string(_value); }","path":"std/experimental/perpetual.d","position":57,"original_position":57,"commit_id":"91d474c81eaebd6fd03b395c997bb13ad040faf6","original_commit_id":"91d474c81eaebd6fd03b395c997bb13ad040faf6","user":{"login":"JackStouffer","id":680068,"avatar_url":"https://avatars.githubusercontent.com/u/680068?v=3","gravatar_id":"","url":"https://api.github.com/users/JackStouffer","html_url":"https://github.com/JackStouffer","followers_url":"https://api.github.com/users/JackStouffer/followers","following_url":"https://api.github.com/users/JackStouffer/following{/other_user}","gists_url":"https://api.github.com/users/JackStouffer/gists{/gist_id}","starred_url":"https://api.github.com/users/JackStouffer/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/JackStouffer/subscriptions","organizations_url":"https://api.github.com/users/JackStouffer/orgs","repos_url":"https://api.github.com/users/JackStouffer/repos","events_url":"https://api.github.com/users/JackStouffer/events{/privacy}","received_events_url":"https://api.github.com/users/JackStouffer/received_events","type":"User","site_admin":false},"body":"This code unnecessarily allocates. Please fix by using the overload shown in http://dlang.org/phobos/std_format.html#.formatValue.10\r\n\r\nThis applies to all `toString()` functions in this code.","created_at":"2015-09-19T17:08:04Z","updated_at":"2015-09-19T17:08:04Z","html_url":"https://github.com/D-Programming-Language/phobos/pull/3625#discussion_r39921477","pull_request_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625","_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments/39921477"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3625#discussion_r39921477"},"pull_request":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625"}}},"pull_request":{"url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625","id":44038654,"html_url":"https://github.com/D-Programming-Language/phobos/pull/3625","diff_url":"https://github.com/D-Programming-Language/phobos/pull/3625.diff","patch_url":"https://github.com/D-Programming-Language/phobos/pull/3625.patch","issue_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3625","number":3625,"state":"open","locked":false,"title":"perpetual: new module for mapping value types into memory","user":{"login":"sdegtiarev","id":5247173,"avatar_url":"https://avatars.githubusercontent.com/u/5247173?v=3","gravatar_id":"","url":"https://api.github.com/users/sdegtiarev","html_url":"https://github.com/sdegtiarev","followers_url":"https://api.github.com/users/sdegtiarev/followers","following_url":"https://api.github.com/users/sdegtiarev/following{/other_user}","gists_url":"https://api.github.com/users/sdegtiarev/gists{/gist_id}","starred_url":"https://api.github.com/users/sdegtiarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdegtiarev/subscriptions","organizations_url":"https://api.github.com/users/sdegtiarev/orgs","repos_url":"https://api.github.com/users/sdegtiarev/repos","events_url":"https://api.github.com/users/sdegtiarev/events{/privacy}","received_events_url":"https://api.github.com/users/sdegtiarev/received_events","type":"User","site_admin":false},"body":"I rewrote std.perpetual module to be based on top of std.mmfile.\r\nIt becomes clear that high-level data handling should be separate from low-level shared memory allocation. In addition to architectural advantages, this also clearly answers the question: what new the perpetual module added to existing functionality.\r\n","created_at":"2015-09-02T20:31:16Z","updated_at":"2015-09-19T17:08:04Z","closed_at":null,"merged_at":null,"merge_commit_sha":"6e671246205b71b52323bb7e62b5007a0456307f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625/commits","review_comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625/comments","review_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3625/comments","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/91d474c81eaebd6fd03b395c997bb13ad040faf6","head":{"label":"sdegtiarev:master","ref":"master","sha":"91d474c81eaebd6fd03b395c997bb13ad040faf6","user":{"login":"sdegtiarev","id":5247173,"avatar_url":"https://avatars.githubusercontent.com/u/5247173?v=3","gravatar_id":"","url":"https://api.github.com/users/sdegtiarev","html_url":"https://github.com/sdegtiarev","followers_url":"https://api.github.com/users/sdegtiarev/followers","following_url":"https://api.github.com/users/sdegtiarev/following{/other_user}","gists_url":"https://api.github.com/users/sdegtiarev/gists{/gist_id}","starred_url":"https://api.github.com/users/sdegtiarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdegtiarev/subscriptions","organizations_url":"https://api.github.com/users/sdegtiarev/orgs","repos_url":"https://api.github.com/users/sdegtiarev/repos","events_url":"https://api.github.com/users/sdegtiarev/events{/privacy}","received_events_url":"https://api.github.com/users/sdegtiarev/received_events","type":"User","site_admin":false},"repo":{"id":40326013,"name":"phobos","full_name":"sdegtiarev/phobos","owner":{"login":"sdegtiarev","id":5247173,"avatar_url":"https://avatars.githubusercontent.com/u/5247173?v=3","gravatar_id":"","url":"https://api.github.com/users/sdegtiarev","html_url":"https://github.com/sdegtiarev","followers_url":"https://api.github.com/users/sdegtiarev/followers","following_url":"https://api.github.com/users/sdegtiarev/following{/other_user}","gists_url":"https://api.github.com/users/sdegtiarev/gists{/gist_id}","starred_url":"https://api.github.com/users/sdegtiarev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sdegtiarev/subscriptions","organizations_url":"https://api.github.com/users/sdegtiarev/orgs","repos_url":"https://api.github.com/users/sdegtiarev/repos","events_url":"https://api.github.com/users/sdegtiarev/events{/privacy}","received_events_url":"https://api.github.com/users/sdegtiarev/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/sdegtiarev/phobos","description":"The standard library of the D programming language","fork":true,"url":"https://api.github.com/repos/sdegtiarev/phobos","forks_url":"https://api.github.com/repos/sdegtiarev/phobos/forks","keys_url":"https://api.github.com/repos/sdegtiarev/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sdegtiarev/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sdegtiarev/phobos/teams","hooks_url":"https://api.github.com/repos/sdegtiarev/phobos/hooks","issue_events_url":"https://api.github.com/repos/sdegtiarev/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/sdegtiarev/phobos/events","assignees_url":"https://api.github.com/repos/sdegtiarev/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/sdegtiarev/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/sdegtiarev/phobos/tags","blobs_url":"https://api.github.com/repos/sdegtiarev/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sdegtiarev/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sdegtiarev/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/sdegtiarev/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sdegtiarev/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/sdegtiarev/phobos/languages","stargazers_url":"https://api.github.com/repos/sdegtiarev/phobos/stargazers","contributors_url":"https://api.github.com/repos/sdegtiarev/phobos/contributors","subscribers_url":"https://api.github.com/repos/sdegtiarev/phobos/subscribers","subscription_url":"https://api.github.com/repos/sdegtiarev/phobos/subscription","commits_url":"https://api.github.com/repos/sdegtiarev/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/sdegtiarev/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/sdegtiarev/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/sdegtiarev/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/sdegtiarev/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/sdegtiarev/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sdegtiarev/phobos/merges","archive_url":"https://api.github.com/repos/sdegtiarev/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sdegtiarev/phobos/downloads","issues_url":"https://api.github.com/repos/sdegtiarev/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/sdegtiarev/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/sdegtiarev/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/sdegtiarev/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sdegtiarev/phobos/labels{/name}","releases_url":"https://api.github.com/repos/sdegtiarev/phobos/releases{/id}","created_at":"2015-08-06T20:42:36Z","updated_at":"2015-08-06T20:42:40Z","pushed_at":"2015-09-19T16:38:29Z","git_url":"git://github.com/sdegtiarev/phobos.git","ssh_url":"git@github.com:sdegtiarev/phobos.git","clone_url":"https://github.com/sdegtiarev/phobos.git","svn_url":"https://github.com/sdegtiarev/phobos","homepage":"dlang.org/phobos","size":45020,"stargazers_count":0,"watchers_count":0,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":0,"forks":1,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"D-Programming-Language:master","ref":"master","sha":"b65b717dcba7d6b86cbedd7cf632e93d67ede392","user":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"repo":{"id":1257084,"name":"phobos","full_name":"D-Programming-Language/phobos","owner":{"login":"D-Programming-Language","id":565913,"avatar_url":"https://avatars.githubusercontent.com/u/565913?v=3","gravatar_id":"","url":"https://api.github.com/users/D-Programming-Language","html_url":"https://github.com/D-Programming-Language","followers_url":"https://api.github.com/users/D-Programming-Language/followers","following_url":"https://api.github.com/users/D-Programming-Language/following{/other_user}","gists_url":"https://api.github.com/users/D-Programming-Language/gists{/gist_id}","starred_url":"https://api.github.com/users/D-Programming-Language/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/D-Programming-Language/subscriptions","organizations_url":"https://api.github.com/users/D-Programming-Language/orgs","repos_url":"https://api.github.com/users/D-Programming-Language/repos","events_url":"https://api.github.com/users/D-Programming-Language/events{/privacy}","received_events_url":"https://api.github.com/users/D-Programming-Language/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/D-Programming-Language/phobos","description":"The standard library of the D programming language","fork":false,"url":"https://api.github.com/repos/D-Programming-Language/phobos","forks_url":"https://api.github.com/repos/D-Programming-Language/phobos/forks","keys_url":"https://api.github.com/repos/D-Programming-Language/phobos/keys{/key_id}","collaborators_url":"https://api.github.com/repos/D-Programming-Language/phobos/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/D-Programming-Language/phobos/teams","hooks_url":"https://api.github.com/repos/D-Programming-Language/phobos/hooks","issue_events_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/events{/number}","events_url":"https://api.github.com/repos/D-Programming-Language/phobos/events","assignees_url":"https://api.github.com/repos/D-Programming-Language/phobos/assignees{/user}","branches_url":"https://api.github.com/repos/D-Programming-Language/phobos/branches{/branch}","tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/tags","blobs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/refs{/sha}","trees_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/trees{/sha}","statuses_url":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/{sha}","languages_url":"https://api.github.com/repos/D-Programming-Language/phobos/languages","stargazers_url":"https://api.github.com/repos/D-Programming-Language/phobos/stargazers","contributors_url":"https://api.github.com/repos/D-Programming-Language/phobos/contributors","subscribers_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscribers","subscription_url":"https://api.github.com/repos/D-Programming-Language/phobos/subscription","commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/commits{/sha}","git_commits_url":"https://api.github.com/repos/D-Programming-Language/phobos/git/commits{/sha}","comments_url":"https://api.github.com/repos/D-Programming-Language/phobos/comments{/number}","issue_comment_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues/comments{/number}","contents_url":"https://api.github.com/repos/D-Programming-Language/phobos/contents/{+path}","compare_url":"https://api.github.com/repos/D-Programming-Language/phobos/compare/{base}...{head}","merges_url":"https://api.github.com/repos/D-Programming-Language/phobos/merges","archive_url":"https://api.github.com/repos/D-Programming-Language/phobos/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/D-Programming-Language/phobos/downloads","issues_url":"https://api.github.com/repos/D-Programming-Language/phobos/issues{/number}","pulls_url":"https://api.github.com/repos/D-Programming-Language/phobos/pulls{/number}","milestones_url":"https://api.github.com/repos/D-Programming-Language/phobos/milestones{/number}","notifications_url":"https://api.github.com/repos/D-Programming-Language/phobos/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/D-Programming-Language/phobos/labels{/name}","releases_url":"https://api.github.com/repos/D-Programming-Language/phobos/releases{/id}","created_at":"2011-01-15T07:00:06Z","updated_at":"2015-09-19T09:10:08Z","pushed_at":"2015-09-19T16:38:31Z","git_url":"git://github.com/D-Programming-Language/phobos.git","ssh_url":"git@github.com:D-Programming-Language/phobos.git","clone_url":"https://github.com/D-Programming-Language/phobos.git","svn_url":"https://github.com/D-Programming-Language/phobos","homepage":"dlang.org/phobos","size":91916,"stargazers_count":628,"watchers_count":628,"language":"D","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":427,"mirror_url":null,"open_issues_count":65,"forks":427,"open_issues":65,"watchers":628,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625"},"html":{"href":"https://github.com/D-Programming-Language/phobos/pull/3625"},"issue":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3625"},"comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/issues/3625/comments"},"review_comments":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625/comments"},"review_comment":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/pulls/3625/commits"},"statuses":{"href":"https://api.github.com/repos/D-Programming-Language/phobos/statuses/91d474c81eaebd6fd03b395c997bb13ad040faf6"}}}}