{"id":15047486,"url":"https://github.com/jdsherbert/threadsafe-singleton-class","last_synced_at":"2026-03-15T18:50:17.509Z","repository":{"id":209862975,"uuid":"725129538","full_name":"JDSherbert/Threadsafe-Singleton-Class","owner":"JDSherbert","description":"C++ Threadsafe Singleton class using mutex and threadlock when accessing instance.","archived":false,"fork":false,"pushed_at":"2023-12-04T17:06:31.000Z","size":14,"stargazers_count":2,"open_issues_count":0,"forks_count":1,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-20T15:59:25.163Z","etag":null,"topics":["boilerplate","boilerplate-template","cpp","cpp11","cpp14","cpp17","cpp20","multithreading","mutex","mutex-lock","mutex-locks","mutex-synchronisation","reference-implementation","singleton","singleton-pattern","singletons"],"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/JDSherbert.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null}},"created_at":"2023-11-29T13:56:37.000Z","updated_at":"2024-11-29T21:32:37.000Z","dependencies_parsed_at":"2023-11-29T15:27:45.804Z","dependency_job_id":"ae67f966-ba7e-4e8b-b8a8-710e64c1aaa6","html_url":"https://github.com/JDSherbert/Threadsafe-Singleton-Class","commit_stats":null,"previous_names":["jdsherbert/threadsafe-singleton-class"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDSherbert%2FThreadsafe-Singleton-Class","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDSherbert%2FThreadsafe-Singleton-Class/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDSherbert%2FThreadsafe-Singleton-Class/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/JDSherbert%2FThreadsafe-Singleton-Class/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/JDSherbert","download_url":"https://codeload.github.com/JDSherbert/Threadsafe-Singleton-Class/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":243475328,"owners_count":20296714,"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":["boilerplate","boilerplate-template","cpp","cpp11","cpp14","cpp17","cpp20","multithreading","mutex","mutex-lock","mutex-locks","mutex-synchronisation","reference-implementation","singleton","singleton-pattern","singletons"],"created_at":"2024-09-24T20:59:03.725Z","updated_at":"2025-12-26T18:52:58.983Z","avatar_url":"https://github.com/JDSherbert.png","language":"C++","readme":"![image](https://github.com/JDSherbert/Threadsafe-Singleton-Class/assets/43964243/8a288a74-0a1e-4fcb-a5d8-608bb7c9d46b)\n\n\n# Threadsafe Singleton Class\n\n\u003c!-- Header Start --\u003e\n\u003ca href = \"https://learn.microsoft.com/en-us/cpp/cpp-language\"\u003e \u003cimg height=\"40\" img width=\"40\" src=\"https://cdn.simpleicons.org/c++\"\u003e \u003c/a\u003e\n\u003cimg align=\"right\" alt=\"Stars Badge\" src=\"https://img.shields.io/github/stars/jdsherbert/Threadsafe-Singleton-Class?label=%E2%AD%90\"/\u003e\n\u003cimg align=\"right\" alt=\"Forks Badge\" src=\"https://img.shields.io/github/forks/jdsherbert/Threadsafe-Singleton-Class?label=%F0%9F%8D%B4\"/\u003e\n\u003cimg align=\"right\" alt=\"Watchers Badge\" src=\"https://img.shields.io/github/watchers/jdsherbert/Threadsafe-Singleton-Class?label=%F0%9F%91%81%EF%B8%8F\"/\u003e\n\u003cimg align=\"right\" alt=\"Issues Badge\" src=\"https://img.shields.io/github/issues/jdsherbert/Threadsafe-Singleton-Class?label=%E2%9A%A0%EF%B8%8F\"/\u003e\n\u003cimg align=\"right\" src=\"https://hits.seeyoufarm.com/api/count/incr/badge.svg?url=https%3A%2F%2Fgithub.com%2FJDSherbert%2FThreadsafe-Singleton-Class%2Fhit-counter%2FREADME\u0026count_bg=%2379C83D\u0026title_bg=%23555555\u0026labelColor=0E1128\u0026title=🔍\u0026style=for-the-badge\"\u003e\n\u003c!-- Header End --\u003e \n\n-----------------------------------------------------------------------\n\n\u003ca href=\"https://learn.microsoft.com/en-us/cpp/cpp-language\"\u003e \n  \u003cimg align=\"left\" alt=\"C++ Template\" src=\"https://img.shields.io/badge/C++%20Template-black?style=for-the-badge\u0026logo=cpp\u0026logoColor=white\u0026color=black\u0026labelColor=black\"\u003e \u003c/a\u003e\n  \n\u003ca href=\"https://choosealicense.com/licenses/mit/\"\u003e \n  \u003cimg align=\"right\" alt=\"License\" src=\"https://img.shields.io/badge/License%20:%20MIT-black?style=for-the-badge\u0026logo=mit\u0026logoColor=white\u0026color=black\u0026labelColor=black\"\u003e \u003c/a\u003e\n  \n\u003cbr\u003e\u003c/br\u003e\n\n-----------------------------------------------------------------------\n## Overview\n\nCreating a thread-safe singleton in C++ requires handling the potential race conditions that can occur when multiple threads attempt to access the singleton instance concurrently. One common approach is to use the double-checked locking pattern. \nThis example uses the mutex functions from the mutex library.\n\nPlease note that in modern C++, you can use C++11's `std::call_once` with a `std::once_flag` instead of manually managing a mutex. This is generally considered a safer and more convenient option. However, the above example demonstrates the basic concept of thread safety in a singleton.\n\n\n-----------------------------------------------------------------------\n\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdsherbert%2Fthreadsafe-singleton-class","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fjdsherbert%2Fthreadsafe-singleton-class","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fjdsherbert%2Fthreadsafe-singleton-class/lists"}