class Profiler {
public:
Profiler();
~Profiler() { }
// This gives us a global version without limiting us to only 1. We can make other Profiler
// objects if we want.
static Profiler &GetGlobalInstance() {
static Profiler prof;
return prof;
}
[...] stuff
};
Then, you know, modify it accordingly if you need an instance per thread, or if you need to ensure synchronization is handled, or whatever.
Show differencesHistory of post edits
#Actualachild
Posted 30 October 2012 - 11:53 AM
An alternative type of having an instance in itself (I realize this isn't exactly what you're trying to do)
#2achild
Posted 30 October 2012 - 11:51 AM
An alternative (what are you trying to do anyway?)
class Profiler {
public:
Profiler();
~Profiler() { }
// This gives us a global version without limiting us to only 1. We can make other Profiler
// objects if we want.
static Profiler &GetGlobalInstance() {
static Profiler prof;
return prof;
}
[...] stuff
};
Then, you know, modify it accordingly if you need an instance per thread, or if you need to ensure synchronization is handled, or whatever.
#1achild
Posted 30 October 2012 - 11:50 AM
An alternative (what are you trying to do anyway?)
class Profiler {
public:
Profiler();
~Profiler() { }
// This gives us a global version without limiting us to only 1. We can make other Profiler
// objects if we want.
static Profiler &GetGlobalInstance() {
static Profiler prof;
return prof;
}
[...] stuff
};
Then, you know, add stuff if you need an instance per thread, or if you need to ensure synchronization is handled, or whatever.