Questions tagged [singleton]
The singleton is a design pattern to ensure that exactly one application-wide instance of a particular class exists.
177 questions
4votes
1answer
168views
Alpha finance trader singleton
I used to write singleton in Python, which actually Alpha only need to initialize once and the trading bot will run forever. For example in main.py: ...
0votes
1answer
145views
Singleton generic implementation of simple LinkedList
I would like to ask if the implementation is ok, and what I can improve. Although I'm not sure if the Singleton is working properly. ...
0votes
1answer
122views
Rust: Unsecure Static Once
I am basically a beginner, so I Wrote some code that implements a zero cost singleton, through it will crash your program if you have a MMU. ...
1vote
2answers
571views
C++ Settings Manager
I'm starting a new project, and it needs to be set up using YAML files. To handle all the settings, I've created a singleton class, I'd like you guys to review. Here is the header: ...
3votes
1answer
5kviews
Polly AddPolicyRegistry() with factory and registered dependency injection service instances?
The Microsoft.Extensions method for Polly, to use policies via dependency injection, serviceCollection.AddPolicyRegistry() only allows to add already created ...
3votes
1answer
232views
Singleton in Ruby without using Singleton module or class variable
When I need a singleton class in my Ruby code (for example, single logger for multiple classes) I usually use code like this: ...
5votes
2answers
494views
Singleton metaclass for each argument set compatible with Pickle
I am creating a metaclass which ensures that instances of an actual class A are kind of singletons. But rather than having only single instance of ...
1vote
3answers
399views
Singleton MongoClient instance provider
A Java service that connects to MongoDB in production, but opened connection count is too much. It affects on MongoDb performance, so I have come up with a solution that provides only one ...
0votes
1answer
951views
Generic Meyers Singleton implementation in C++
Is this a correct implementation of a generic Meyers Singleton in C++17? Any tips appreciated. Singleton.h ...
3votes
2answers
6kviews
ASP.NET Core singleton with a thread-safe property that can be changed
Thanks to ASP.NET Core dependency injection, there's no need to follow the Singleton pattern; any class will do. What I want to do is to have a class that will store a value that'll be used by another ...
1vote
2answers
2kviews
Magic Static in Singleton Template
I recently was reading an article labeled "Modern C++ Singleton Template". The proposed solution used C++11 feature of Magic Statics (N2660). I wanted to adapt it for an own project in "...
0votes
1answer
107views
Inheritance with Singletons [closed]
The problem / background I have a project, BusinessProject, that currently stores some static data in memory using the Singleton pattern - we'll call this class ...
0votes
1answer
1kviews
Fast efficient C++ Singleton template with proper constructor and destruction order
I wrote a Singleton template, with examples, google tests and README https://github.com/erez-strauss/init_singleton/blob/master/singleton.h The usage can be as simple as: ...
2votes
0answers
152views
SharedPreferences singleton wrapper
I was wondering wether my implementation of the PreferenceService below is thread safe or could cause memory leaks. Android Studio gives me the warning "Do not place Android context classes in ...
1vote
0answers
45views
Usage of global variable for dynamic value that must be declared compile time [closed]
I've been trying to make a work-around for global usage; however, I can't seem to find an alternative. I'd like to create a C++ suffix function which converts pixels to millimeters. A custom gui ...