Skip to main content

Questions tagged [singleton]

The singleton is a design pattern to ensure that exactly one application-wide instance of a particular class exists.

4 votes
1 answer
224 views

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: ...
tung's user avatar
  • 127
0 votes
1 answer
163 views

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. ...
John's user avatar
  • 1
0 votes
1 answer
145 views

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. ...
Delfin's user avatar
  • 101
1 vote
2 answers
601 views

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: ...
X99's user avatar
  • 123
3 votes
1 answer
5k views

The Microsoft.Extensions method for Polly, to use policies via dependency injection, serviceCollection.AddPolicyRegistry() only allows to add already created ...
Erik Hart's user avatar
  • 311
3 votes
1 answer
249 views

When I need a singleton class in my Ruby code (for example, single logger for multiple classes) I usually use code like this: ...
Ivan Olshansky's user avatar
5 votes
2 answers
546 views

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 ...
Tomáš Hons's user avatar
1 vote
3 answers
429 views

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 ...
fuat's user avatar
  • 162
0 votes
1 answer
995 views

Is this a correct implementation of a generic Meyers Singleton in C++17? Any tips appreciated. Singleton.h ...
Tom Gebel's user avatar
  • 360
3 votes
2 answers
6k views

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 ...
Léster's user avatar
  • 205
1 vote
2 answers
2k views

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 "...
Heinz's user avatar
  • 11
0 votes
1 answer
120 views

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 ...
laventnc's user avatar
  • 113
0 votes
1 answer
2k views

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: ...
user5673656's user avatar
2 votes
0 answers
165 views

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 ...
nullmn's user avatar
  • 121
1 vote
0 answers
64 views

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 ...
Michael Choi's user avatar

15 30 50 per page
1
2 3 4 5
12