\
forward.h \
\
+ mem/Page.cc \
+ mem/Page.h \
+ mem/PagePool.cc \
+ mem/PagePool.h \
+ mem/Pages.cc \
+ mem/Pages.h \
mem/PageStack.cc \
mem/PageStack.h \
mem/Segment.cc \
--- /dev/null
+/*
+ * $Id$
+ *
+ * DEBUG: section 54 Interprocess Communication
+ *
+ */
+
+#include "config.h"
+#include "ipc/mem/Page.h"
+
+// TODO: implement
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+#ifndef SQUID_IPC_MEM_PAGE_H
+#define SQUID_IPC_MEM_PAGE_H
+
+#if HAVE_IOSFWD
+#include <iosfwd>
+#endif
+
+namespace Ipc {
+
+namespace Mem {
+
+/// Shared memory page identifier, address, or handler
+class PageId {
+public:
+ PageId(): segment(0), number(0) {}
+
+ // uint32_t pool; ///< page pool ID within Squid; unused for now
+ uint32_t segment; ///< memory segment ID within the pool
+ uint32_t number; ///< page number within the segment
+};
+
+/// writes page address (e.g., "sh_page5.3"), for debugging
+std::ostream &operator <<(std::ostream &os, const PageId &page);
+
+} // namespace Mem
+
+} // namespace Ipc
+
+#endif // SQUID_IPC_MEM_PAGE_H
--- /dev/null
+/*
+ * $Id$
+ *
+ * DEBUG: section 54 Interprocess Communication
+ *
+ */
+
+#include "config.h"
+#include "ipc/mem/PagePool.h"
+
+// TODO: implement
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+#ifndef SQUID_IPC_MEM_PAGE_POOL_H
+#define SQUID_IPC_MEM_PAGE_POOL_H
+
+#include "ipc/mem/Page.h"
+#include "ipc/mem/Segment.h"
+
+namespace Ipc {
+
+namespace Mem {
+
+/// Atomic container of shared memory pages. Implemented using a collection of
+/// Segments, each with a PageStack index of free pages.
+class PagePool {
+public:
+ /// creates a new shared page pool that can hold up to capacity pages
+ PagePool(const String &id, const unsigned int capacity);
+ /// attaches to the identified shared page pool
+ PagePool(const String &id);
+
+ /// sets page ID and returns true unless no free pages are found
+ bool get(PageId &page);
+ /// makes identified page available as a free page to future get() callers
+ void put(const PageId &page);
+
+private:
+ Segment meta; ///< shared memory segment to store our metadata
+ /// TODO: Shared *shared; ///< our metadata, shared among all pool users
+
+ /// TODO: typedef collection<Segment*> Store; ///< storage for pages
+ /// TODO: Store store; ///< pages (with free page indexes)
+};
+
+} // namespace Mem
+
+} // namespace Ipc
+
+#endif // SQUID_IPC_MEM_PAGE_POOL_H
--- /dev/null
+/*
+ * $Id$
+ *
+ * DEBUG: section 54 Interprocess Communication
+ *
+ */
+
+#include "config.h"
+#include "ipc/mem/Pages.h"
+
+// TODO: Implement using a single PagePool instance, for now.
+// Eventually, we may have pools dedicated to memory caching, disk I/O, etc.
--- /dev/null
+/*
+ * $Id$
+ *
+ */
+
+#ifndef SQUID_IPC_MEM_PAGES_H
+#define SQUID_IPC_MEM_PAGES_H
+
+namespace Ipc {
+
+namespace Mem {
+
+class PageId;
+
+/// initializes and configures shared memory [pools] for all kids
+void Init();
+
+/// attaches this kid to the already configured shared memory [pools]
+void Attach();
+
+
+/* Single page manipulation */
+
+/// sets page ID and returns true unless no free pages are found
+bool GetPage(PageId &page);
+
+/// makes identified page available as a free page to future GetPage() callers
+void PutPage(const PageId &page);
+
+/// converts page handler into a temporary writeable shared memory pointer
+void *PagePointer(const PageId &page);
+
+
+/* Limits and statistics */
+
+/// the total number of shared memory bytes that can be in use at any time
+uint64_t Limit();
+
+/// approximate total number of shared memory bytes used now
+uint64_t Level();
+
+/// approximate total number of shared memory bytes we can allocate now
+inline uint64_t Available() { return Limit() - Level(); }
+
+} // namespace Mem
+
+} // namespace Ipc
+
+#endif // SQUID_IPC_MEM_PAGES_H