]> git.ipfire.org Git - thirdparty/squid.git/blobdiff - src/ipc/mem/PageStack.h
Docs: Copyright updates for 2018 (#114)
[thirdparty/squid.git] / src / ipc / mem / PageStack.h
index 85aea0901d4d781272d06df6968c72cd50298da0..3df60a19e8a572444a283d5fd0a23df38a843a95 100644 (file)
@@ -1,12 +1,17 @@
 /*
- * $Id$
+ * Copyright (C) 1996-2018 The Squid Software Foundation and contributors
  *
+ * Squid software is distributed under GPLv2+ license and includes
+ * contributions from numerous individuals and organizations.
+ * Please see the COPYING and CONTRIBUTORS files for details.
  */
 
 #ifndef SQUID_IPC_MEM_PAGE_STACK_H
 #define SQUID_IPC_MEM_PAGE_STACK_H
 
-#include "ipc/AtomicWord.h"
+#include "ipc/mem/FlexibleArray.h"
+
+#include <atomic>
 
 namespace Ipc
 {
@@ -25,12 +30,11 @@ public:
     typedef uint32_t Value; ///< stack item type (a free page number)
 
     PageStack(const uint32_t aPoolId, const unsigned int aCapacity, const size_t aPageSize);
-    ~PageStack();
 
     unsigned int capacity() const { return theCapacity; }
     size_t pageSize() const { return thePageSize; }
     /// lower bound for the number of free pages
-    unsigned int size() const { return max(0, theSize.get()); }
+    unsigned int size() const { return max(0, theSize.load()); }
 
     /// sets value and returns true unless no free page numbers are found
     bool pop(PageId &page);
@@ -60,15 +64,15 @@ private:
     const Offset theCapacity; ///< stack capacity, i.e. theItems size
     const size_t thePageSize; ///< page size, used to calculate shared memory size
     /// lower bound for the number of free pages (may get negative!)
-    Atomic::WordT<Offset> theSize;
+    std::atomic<Offset> theSize;
 
     /// last readable item index; just a hint, not a guarantee
-    Atomic::WordT<Offset> theLastReadable;
+    std::atomic<Offset> theLastReadable;
     /// first writable item index; just a hint, not a guarantee
-    Atomic::WordT<Offset> theFirstWritable;
+    std::atomic<Offset> theFirstWritable;
 
-    typedef Atomic::WordT<Value> Item;
-    Item *theItems; ///< page number storage
+    typedef std::atomic<Value> Item;
+    Ipc::Mem::FlexibleArray<Item> theItems; ///< page number storage
 };
 
 } // namespace Mem
@@ -76,3 +80,4 @@ private:
 } // namespace Ipc
 
 #endif // SQUID_IPC_MEM_PAGE_STACK_H
+