|
Notes: Initializing the PrimaryOnlyService::_executor in the POS constructor is not straight forward as it access derived class override methods getServiceName() and getThreadPoolLimits(). To make this possible we should make those methods as Static override using Curiously Recursive Template Pattern (CRTP) or using alternative solution suggested by Ben during offline discussion
Reposting Ben's idea.
Well, the simplest alternative looks like this:
class PrimaryOnlyService::Options {
|
public:
|
ThreadPool::Limits getThreadPoolLimits() const;
|
...
|
};
|
PrimaryOnlyService::PrimaryOnlyService(ServiceContext *, PrimaryOnlyServiceOptions);
|
PrimaryOnlyService::PrimaryOnlyService(ServiceContext *, PrimaryOnlyServiceOptions);
Options could be pure virtual or plain old data. The former is probably more flexible?
It is just about the same amount of work as making it CRTP though.
|