{"id":15047241,"url":"https://github.com/mickaelblet/thread","last_synced_at":"2026-01-30T09:46:47.363Z","repository":{"id":101617903,"uuid":"608437630","full_name":"MickaelBlet/Thread","owner":"MickaelBlet","description":"One header file std::thread for C++98 ","archived":false,"fork":false,"pushed_at":"2024-02-12T03:18:22.000Z","size":72,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T19:47:46.928Z","etag":null,"topics":["cpp98","cpp98-compatible","header-only","header-only-library"],"latest_commit_sha":null,"homepage":"","language":"C++","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/MickaelBlet.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2023-03-02T02:26:53.000Z","updated_at":"2023-09-15T08:41:53.000Z","dependencies_parsed_at":"2024-02-12T04:26:17.315Z","dependency_job_id":"89ecfa29-ef84-4656-a21d-f837f97ccfe9","html_url":"https://github.com/MickaelBlet/Thread","commit_stats":null,"previous_names":[],"tags_count":6,"template":false,"template_full_name":null,"purl":"pkg:github/MickaelBlet/Thread","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MickaelBlet%2FThread","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MickaelBlet%2FThread/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MickaelBlet%2FThread/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MickaelBlet%2FThread/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/MickaelBlet","download_url":"https://codeload.github.com/MickaelBlet/Thread/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/MickaelBlet%2FThread/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":259919352,"owners_count":22932069,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cpp98","cpp98-compatible","header-only","header-only-library"],"created_at":"2024-09-24T20:55:39.624Z","updated_at":"2026-01-30T09:46:47.338Z","avatar_url":"https://github.com/MickaelBlet.png","language":"C++","readme":"# Thread\n\nstd::thread for C++ 98 on one header only file.\n\n[thread.h](include/blet/thread.h)\n\n## QuickStart\n\n``` cpp\n#include \u003ciostream\u003e\n\n#include \"blet/thread.h\"\n\nvoid functionExampleWithRefArg(double\u0026 d) {\n    d += 1.0;\n    std::cout \u003c\u003c \"Inside functionExampleWithRefArg(\" \u003c\u003c d \u003c\u003c \")\" \u003c\u003c std::endl;\n}\n\nvoid functionExampleWithArg(double d) {\n    std::cout \u003c\u003c \"Inside functionExampleWithArg(\" \u003c\u003c d \u003c\u003c \")\" \u003c\u003c std::endl;\n}\n\nvoid functionExample(void) {\n    std::cout \u003c\u003c \"Inside functionExample\" \u003c\u003c std::endl;\n}\n\nint main(int argc, char* argv[]) {\n    (void)argc;\n    (void)argv;\n\n    std::cout \u003c\u003c \"=== Start ===\" \u003c\u003c std::endl;\n    blet::Thread thrd;\n    thrd.start(\u0026functionExample);\n    thrd.join();\n    thrd.start(\u0026functionExampleWithArg, 42.42);\n    thrd.join();\n    double d = 42.42;\n    // type of first argument (double\u0026)\n    thrd.start\u003cdouble\u0026\u003e(\u0026functionExampleWithRefArg, d);\n    thrd.join();\n    std::cout \u003c\u003c \"New value of d: \" \u003c\u003c d \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"===  End  ===\" \u003c\u003c std::endl;\n    return 0;\n}\n\n// output:\n// === Start ===\n// Inside functionExample\n// Inside functionExampleWithArg(42.42)\n// Inside functionExampleWithRefArg(43.42)\n// New value of d: 43.42\n// ===  End  ===\n```\n\n## Member method\n\n``` cpp\n#include \u003ciostream\u003e\n\n#include \"blet/thread.h\"\n\nclass Example {\n  public:\n    Example() :\n        _privateVar(0) {}\n\n    void methodExampleWithRefArg(double\u0026 d) {\n        d += 1.0;\n        ++_privateVar;\n        std::cout \u003c\u003c \"Inside methodExampleWithRefArg(\" \u003c\u003c d \u003c\u003c \")\" \u003c\u003c std::endl;\n    }\n\n    void methodExampleWithArg(double d) {\n        ++_privateVar;\n        std::cout \u003c\u003c \"Inside methodExampleWithArg(\" \u003c\u003c d \u003c\u003c \")\" \u003c\u003c std::endl;\n    }\n\n    void methodExample(void) {\n        ++_privateVar;\n        std::cout \u003c\u003c \"Inside methodExample\" \u003c\u003c std::endl;\n    }\n\n    const int\u0026 getPrivateVar() const {\n        return _privateVar;\n    }\n\n  private:\n    int _privateVar;\n};\n\nint main(int argc, char* argv[]) {\n    (void)argc;\n    (void)argv;\n\n    std::cout \u003c\u003c \"=== Start ===\" \u003c\u003c std::endl;\n    Example example;\n    std::cout \u003c\u003c \"Example private var: \" \u003c\u003c example.getPrivateVar() \u003c\u003c std::endl;\n    blet::Thread thrd;\n    thrd.start(\u0026Example::methodExample, \u0026example);\n    thrd.join();\n    std::cout \u003c\u003c \"Example private var: \" \u003c\u003c example.getPrivateVar() \u003c\u003c std::endl;\n    thrd.start(\u0026Example::methodExampleWithArg, \u0026example, 42.42);\n    thrd.join();\n    std::cout \u003c\u003c \"Example private var: \" \u003c\u003c example.getPrivateVar() \u003c\u003c std::endl;\n    double d = 42.42;\n    // type of object, type of first argument (double\u0026)\n    thrd.start\u003cExample, double\u0026\u003e(\u0026Example::methodExampleWithRefArg, \u0026example, d);\n    thrd.join();\n    std::cout \u003c\u003c \"New value of d: \" \u003c\u003c d \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"Example private var: \" \u003c\u003c example.getPrivateVar() \u003c\u003c std::endl;\n    std::cout \u003c\u003c \"===  End  ===\" \u003c\u003c std::endl;\n    return 0;\n}\n\n// output:\n// === Start ===\n// Example private var: 0\n// Inside methodExample\n// Example private var: 1\n// Inside methodExampleWithArg(42.42)\n// Example private var: 2\n// Inside methodExampleWithRefArg(43.42)\n// New value of d: 43.42\n// Example private var: 3\n// ===  End  ===\n```","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickaelblet%2Fthread","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmickaelblet%2Fthread","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmickaelblet%2Fthread/lists"}