Skip to main content
2 votes
3 answers
240 views

This question is about the singleton pattern in modern C++ and one of its limitations in particular. I can implement the singleton pattern like this: class Logger { public: static Logger& ...
Hendrik's user avatar
  • 796
0 votes
3 answers
255 views

I am storing some settings for my application in a JSON file located alongside the application .exe. I want to load these settings only once, lazily, the first time one of them is needed. So for ...
Theodor Zoulias's user avatar
Best practices
2 votes
4 replies
129 views

Follow-up on this question: Singletons: good design or a crutch? It is true, that using singletons can make testing harder, and bugs can hide behind them. GoF defines singleton to use when: Global ...
zerocukor287's user avatar
  • 1,769
0 votes
0 answers
125 views

Here's a piece of Qt code: int main(int argc, char *argv[]) { QGuiApplication app(argc, argv); QGuiApplication app2(argc, argv); The first constructor call returns, the second does not. I ...
Ivan's user avatar
  • 527
3 votes
1 answer
91 views

I want to instantiate class with default value. Class have required parameters. Class must be singleton (can be implemented with smt other than metaclass). Data must be updated if try to instantiate ...
big_cat's user avatar
  • 67
0 votes
0 answers
104 views

According to [1]: https://learn.microsoft.com/en-us/dotnet/fundamentals/networking/http/httpclient-guidelines, the recommended approach for handling HTTP requests is to use singleton or static ...
florins's user avatar
  • 1,665
1 vote
2 answers
157 views

Everyone knows Singletons. Here is one: public class MySingleton { private MySingleton() { } public static MySingleton GetInstance() { return instance ??= new MySingleton(); } ...
Thomas W.'s user avatar
  • 61.2k
0 votes
0 answers
57 views

This is a Kotlin question, although it originated from Android Jetpack Compose. I defined the Context.dataStore extension property in the recommended way: val Context.dataStore: DataStore<...
18446744073709551615's user avatar
1 vote
1 answer
78 views

I have a tracker which I'd like to be a singleton class for usage throughout the app. For instance, I came up with the following: export class MyTracker = { private static instance: MyTracker | ...
EDJ's user avatar
  • 1,073
0 votes
0 answers
52 views

I'm trying to browse the C++ code for an embedded project using Doxygen 1.8.13. I find the call/caller graphs very useful for this, but the project includes several singleton classes. Each of these ...
Dave Tweed's user avatar
2 votes
3 answers
230 views

Does the singleton pattern in C++ have processor overhead? If it does, how much? static Singleton& getInstance() { static Singleton instance; return instance; } //... int ...
fiqcerzvgm's user avatar
2 votes
2 answers
87 views

For .NET Generic Host it is possible to register multiple implementations of same service interface. When materializing that service the last added is obtained (that is correct even for multiple ...
bairog's user avatar
  • 3,593
0 votes
2 answers
162 views

I have a class AppData that I am going to load as Singleton to store data for use across my Blazor web app. My issue is that the singleton requires some data that is retrieved with asynchronous calls ...
GarudaLead's user avatar
0 votes
1 answer
97 views

I need to perform some action (i. e., log succesfull shutdown) when all registered services in .NET Generic Host are disposed. I hoped IHostApplicationLifetime.ApplicationStopped could help me but it ...
bairog's user avatar
  • 3,593
0 votes
1 answer
230 views

I'm working with SurrealDb, and in their docs here they implement a singleton. However, when you try to implement the same thing using a RocksDb instance it requires an asynchronous step making that ...
Andrew's user avatar
  • 642

15 30 50 per page
1
2 3 4 5
584