PagePool.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 1996-2017 The Squid Software Foundation and contributors
3  *
4  * Squid software is distributed under GPLv2+ license and includes
5  * contributions from numerous individuals and organizations.
6  * Please see the COPYING and CONTRIBUTORS files for details.
7  */
8 
9 #ifndef SQUID_IPC_MEM_PAGE_POOL_H
10 #define SQUID_IPC_MEM_PAGE_POOL_H
11 
12 #include "ipc/mem/Page.h"
13 #include "ipc/mem/PageStack.h"
14 #include "ipc/mem/Pointer.h"
15 
16 namespace Ipc
17 {
18 
19 namespace Mem
20 {
21 
25 class PagePool
26 {
27 public:
29 
30  static Owner *Init(const char *const id, const unsigned int capacity, const size_t pageSize);
31 
32  PagePool(const char *const id);
33 
34  unsigned int capacity() const { return pageIndex->capacity(); }
35  size_t pageSize() const { return pageIndex->pageSize(); }
37  unsigned int size() const { return pageIndex->size(); }
39  size_t level() const { return capacity() - size(); }
41  size_t level(const int purpose) const;
42 
44  bool get(const PageId::Purpose purpose, PageId &page);
46  void put(PageId &page);
48  char *pagePointer(const PageId &page);
49 
50 private:
52  typedef std::atomic<size_t> Levels_t;
55  char *const theBuf;
56 };
57 
58 } // namespace Mem
59 
60 } // namespace Ipc
61 
62 #endif // SQUID_IPC_MEM_PAGE_POOL_H
63 
size_t pageSize() const
Definition: PagePool.h:35
unsigned int size() const
lower bound for the number of free pages
Definition: PagePool.h:37
char *const theBuf
pages storage
Definition: PagePool.h:55
Levels_t *const theLevels
number of shared memory pages used now for each purpose
Definition: PagePool.h:54
unsigned int capacity() const
Definition: PagePool.h:34
static Owner * Init(const char *const id, const unsigned int capacity, const size_t pageSize)
Definition: PagePool.cc:19
std::atomic< size_t > Levels_t
Definition: PagePool.h:52
void put(PageId &page)
makes identified page available as a free page to future get() callers
Definition: PagePool.cc:56
char * pagePointer(const PageId &page)
converts page handler into a temporary writeable shared memory pointer
Definition: PagePool.cc:68
Ipc::Mem::Pointer< PageStack > pageIndex
free pages index
Definition: PagePool.h:51
Shared memory page identifier, address, or handler.
Definition: Page.h:21
PagePool(const char *const id)
Definition: PagePool.cc:27
Ipc::Mem::Owner< PageStack > Owner
Definition: PagePool.h:28
size_t level() const
approximate number of shared memory pages used now
Definition: PagePool.h:39

 

Introduction

Documentation

Support

Miscellaneous

Web Site Translations

Mirrors