]>
git.ipfire.org Git - thirdparty/squid.git/blob - src/ipc/mem/Pages.cc
4 * DEBUG: section 54 Interprocess Communication
9 #include "base/TextException.h"
10 #include "base/RunnersRegistry.h"
11 #include "ipc/mem/PagePool.h"
12 #include "ipc/mem/Pages.h"
16 // Uses a single PagePool instance, for now.
17 // Eventually, we may have pools dedicated to memory caching, disk I/O, etc.
19 // TODO: make pool id more unique so it does not conflict with other Squids?
20 static const char *PagePoolId
= "squid-page-pool";
21 static Ipc::Mem::PagePool
*ThePagePool
= 0;
23 // TODO: make configurable to avoid waste when mem-cached objects are small/big
25 Ipc::Mem::PageSize() {
33 const size_t capacity
= Limit() / PageSize();
34 ThePagePool
= new PagePool(PagePoolId
, capacity
, PageSize());
41 // TODO: make pool id more unique so it does not conflict with other Squid instances?
42 ThePagePool
= new PagePool(PagePoolId
);
46 Ipc::Mem::GetPage(PageId
&page
)
48 return ThePagePool
? ThePagePool
->get(page
) : false;
52 Ipc::Mem::PutPage(PageId
&page
)
55 ThePagePool
->put(page
);
59 Ipc::Mem::PagePointer(const PageId
&page
)
62 return ThePagePool
->pagePointer(page
);
68 // TODO: adjust cache_mem description to say that in SMP mode,
69 // in-transit objects are not allocated using cache_mem. Eventually,
70 // they should not use cache_mem even if shared memory is not used:
71 // in-transit objects have nothing to do with caching.
72 return Config
.memMaxSize
;
75 // TODO: Implement size_t Ipc::Mem::Level()
78 /// initializes shared memory pages
79 class SharedMemPagesRr
: public RegisteredRunner
82 /* RegisteredRunner API */
83 virtual void run(const RunnerRegistry
&);
84 // TODO: cleanup in destructor
87 RunnerRegistrationEntry(rrAfterConfig
, SharedMemPagesRr
);
90 void SharedMemPagesRr::run(const RunnerRegistry
&)
92 // XXX: restore if (!UsingSmp()) return;
94 if (IamMasterProcess())