/// initializes shared memory segments used by IpcIoFile
-class IpcIoRr: public RegisteredRunner
+class IpcIoRr: public Ipc::Mem::RegisteredRunner
{
public:
/* RegisteredRunner API */
IpcIoRr(): owner(NULL) {}
- virtual void run(const RunnerRegistry &);
virtual ~IpcIoRr();
+protected:
+ virtual void create(const RunnerRegistry &);
+
private:
Ipc::FewToFewBiQueue::Owner *owner;
};
RunnerRegistrationEntry(rrAfterConfig, IpcIoRr);
-void IpcIoRr::run(const RunnerRegistry &)
+void IpcIoRr::create(const RunnerRegistry &)
{
if (!UsingSmp())
return;
- if (IamMasterProcess()) {
- Must(!owner);
- // XXX: make capacity configurable
- owner = Ipc::FewToFewBiQueue::Init(ShmLabel, Config.workers, 1, Config.cacheSwap.n_configured, 1 + Config.workers, sizeof(IpcIoMsg), 1024);
- }
+ Must(!owner);
+ // XXX: make capacity configurable
+ owner = Ipc::FewToFewBiQueue::Init(ShmLabel, Config.workers, 1,
+ Config.cacheSwap.n_configured,
+ 1 + Config.workers, sizeof(IpcIoMsg),
+ 1024);
}
IpcIoRr::~IpcIoRr()
/// initializes shared memory segments used by MemStore
-class MemStoreRr: public RegisteredRunner
+class MemStoreRr: public Ipc::Mem::RegisteredRunner
{
public:
/* RegisteredRunner API */
virtual void run(const RunnerRegistry &);
virtual ~MemStoreRr();
+protected:
+ virtual void create(const RunnerRegistry &);
+
private:
MemStoreMap::Owner *owner;
};
RunnerRegistrationEntry(rrAfterConfig, MemStoreRr);
-void MemStoreRr::run(const RunnerRegistry &)
+void MemStoreRr::run(const RunnerRegistry &r)
{
// decide whether to use a shared memory cache if the user did not specify
if (!Config.memShared.configured()) {
" a single worker is running");
}
+ Ipc::Mem::RegisteredRunner::run(r);
+}
+
+void MemStoreRr::create(const RunnerRegistry &)
+{
if (!Config.memShared)
return;
- if (IamMasterProcess()) {
- Must(!owner);
- const int64_t entryLimit = MemStore::EntryLimit();
- if (entryLimit <= 0)
- return; // no memory cache configured or a misconfiguration
- owner = MemStoreMap::Init(ShmLabel, entryLimit);
- }
+ Must(!owner);
+ const int64_t entryLimit = MemStore::EntryLimit();
+ if (entryLimit <= 0)
+ return; // no memory cache configured or a misconfiguration
+ owner = MemStoreMap::Init(ShmLabel, entryLimit);
}
MemStoreRr::~MemStoreRr()
/// initializes shared memory segments used by Rock::SwapDir
-class RockSwapDirRr: public RegisteredRunner
+class RockSwapDirRr: public Ipc::Mem::RegisteredRunner
{
public:
/* RegisteredRunner API */
- virtual void run(const RunnerRegistry &);
virtual ~RockSwapDirRr();
+protected:
+ virtual void create(const RunnerRegistry &);
+
private:
Vector<Rock::SwapDir::DirMap::Owner *> owners;
};
RunnerRegistrationEntry(rrAfterConfig, RockSwapDirRr);
-void RockSwapDirRr::run(const RunnerRegistry &)
+void RockSwapDirRr::create(const RunnerRegistry &)
{
- if (IamMasterProcess()) {
- Must(owners.empty());
- for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
- if (const Rock::SwapDir *const sd = dynamic_cast<Rock::SwapDir *>(INDEXSD(i))) {
- // TODO: check whether entryLimitAllowed() has map here
- Rock::SwapDir::DirMap::Owner *const owner = Rock::SwapDir::DirMap::Init(sd->path, sd->entryLimitAllowed());
- owners.push_back(owner);
- }
+ Must(owners.empty());
+ for (int i = 0; i < Config.cacheSwap.n_configured; ++i) {
+ if (const Rock::SwapDir *const sd = dynamic_cast<Rock::SwapDir *>(INDEXSD(i))) {
+ // TODO: check whether entryLimitAllowed() has map here
+ Rock::SwapDir::DirMap::Owner *const owner =
+ Rock::SwapDir::DirMap::Init(sd->path, sd->entryLimitAllowed());
+ owners.push_back(owner);
}
}
}
}
/// initializes shared memory pages
-class SharedMemPagesRr: public RegisteredRunner
+class SharedMemPagesRr: public Ipc::Mem::RegisteredRunner
{
public:
/* RegisteredRunner API */
SharedMemPagesRr(): owner(NULL) {}
virtual void run(const RunnerRegistry &);
+ virtual void create(const RunnerRegistry &);
+ virtual void open(const RunnerRegistry &);
virtual ~SharedMemPagesRr();
private:
RunnerRegistrationEntry(rrAfterConfig, SharedMemPagesRr);
-void SharedMemPagesRr::run(const RunnerRegistry &)
+void
+SharedMemPagesRr::run(const RunnerRegistry &r)
{
if (!UsingSmp())
return;
return;
}
- if (IamMasterProcess()) {
- Must(!owner);
- owner = Ipc::Mem::PagePool::Init(PagePoolId, Ipc::Mem::PageLimit(), Ipc::Mem::PageSize());
- }
+ Ipc::Mem::RegisteredRunner::run(r);
+}
+void
+SharedMemPagesRr::create(const RunnerRegistry &)
+{
+ Must(!owner);
+ owner = Ipc::Mem::PagePool::Init(PagePoolId, Ipc::Mem::PageLimit(),
+ Ipc::Mem::PageSize());
+}
+
+void
+SharedMemPagesRr::open(const RunnerRegistry &)
+{
Must(!ThePagePool);
ThePagePool = new Ipc::Mem::PagePool(PagePoolId);
}