paul@93 | 1 | /* |
paul@93 | 2 | * A page queue retaining two internal collections of memory pages. |
paul@93 | 3 | * |
paul@93 | 4 | * Copyright (C) 2021 Paul Boddie <paul@boddie.org.uk> |
paul@93 | 5 | * |
paul@93 | 6 | * This program is free software; you can redistribute it and/or |
paul@93 | 7 | * modify it under the terms of the GNU General Public License as |
paul@93 | 8 | * published by the Free Software Foundation; either version 2 of |
paul@93 | 9 | * the License, or (at your option) any later version. |
paul@93 | 10 | * |
paul@93 | 11 | * This program is distributed in the hope that it will be useful, |
paul@93 | 12 | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
paul@93 | 13 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
paul@93 | 14 | * GNU General Public License for more details. |
paul@93 | 15 | * |
paul@93 | 16 | * You should have received a copy of the GNU General Public License |
paul@93 | 17 | * along with this program; if not, write to the Free Software |
paul@93 | 18 | * Foundation, Inc., 51 Franklin Street, Fifth Floor, |
paul@93 | 19 | * Boston, MA 02110-1301, USA |
paul@93 | 20 | */ |
paul@93 | 21 | |
paul@70 | 22 | #pragma once |
paul@70 | 23 | |
paul@70 | 24 | #include <condition_variable> |
paul@70 | 25 | #include <mutex> |
paul@70 | 26 | |
paul@94 | 27 | #include <fsserver/page_queue.h> |
paul@70 | 28 | |
paul@70 | 29 | |
paul@70 | 30 | |
paul@70 | 31 | /* Queues of issued and available pages. */ |
paul@70 | 32 | |
paul@70 | 33 | class PageQueuePartitioned : public PageQueue |
paul@70 | 34 | { |
paul@70 | 35 | protected: |
paul@70 | 36 | Queue _issued, _available; |
paul@70 | 37 | Positions _positions; |
paul@70 | 38 | |
paul@70 | 39 | std::mutex _lock; |
paul@70 | 40 | std::condition_variable _counter; |
paul@70 | 41 | |
paul@70 | 42 | virtual bool _pop(QueueEntry *entry); |
paul@70 | 43 | |
paul@70 | 44 | public: |
paul@74 | 45 | virtual void close(Memory *memory); |
paul@74 | 46 | |
paul@70 | 47 | virtual void pop(PageOwner **owner, Flexpage **flexpage); |
paul@70 | 48 | |
paul@70 | 49 | virtual void push(PageOwner *owner, Flexpage *flexpage); |
paul@70 | 50 | |
paul@70 | 51 | virtual void push_front(PageOwner *owner, Flexpage *flexpage); |
paul@70 | 52 | |
paul@70 | 53 | virtual bool remove(PageOwner *owner, Flexpage *flexpage); |
paul@70 | 54 | }; |
paul@70 | 55 | |
paul@70 | 56 | // vim: tabstop=4 expandtab shiftwidth=4 |