paul@93 | 1 | /* |
paul@93 | 2 | * A page collection abstraction providing pages from a queue to users. |
paul@93 | 3 | * |
paul@343 | 4 | * Copyright (C) 2021, 2022 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@94 | 24 | #include <mem/flexpage.h> |
paul@94 | 25 | #include <mem/memory.h> |
paul@94 | 26 | #include <fsserver/page_owner.h> |
paul@94 | 27 | #include <fsserver/page_queue.h> |
paul@70 | 28 | |
paul@70 | 29 | |
paul@70 | 30 | |
paul@70 | 31 | /* A page collection. */ |
paul@70 | 32 | |
paul@72 | 33 | class Pages |
paul@70 | 34 | { |
paul@70 | 35 | protected: |
paul@72 | 36 | Memory *_memory; |
paul@70 | 37 | PageQueue *_queue; |
paul@70 | 38 | |
paul@343 | 39 | virtual Flexpage *remove(); |
paul@343 | 40 | |
paul@70 | 41 | public: |
paul@72 | 42 | explicit Pages(Memory *memory, PageQueue *queue); |
paul@70 | 43 | |
paul@74 | 44 | virtual ~Pages(); |
paul@70 | 45 | |
paul@70 | 46 | virtual bool reserve(PageOwner *owner, Flexpage *flexpage); |
paul@70 | 47 | |
paul@70 | 48 | virtual Flexpage *flexpage(); |
paul@70 | 49 | |
paul@70 | 50 | virtual void queue(PageOwner *owner, Flexpage *flexpage); |
paul@70 | 51 | |
paul@70 | 52 | virtual void release(Flexpage *flexpage); |
paul@70 | 53 | }; |
paul@70 | 54 | |
paul@70 | 55 | // vim: tabstop=4 expandtab shiftwidth=4 |