rambrain
managedSwap.cpp
Go to the documentation of this file.
1 /* rambrain - a dynamical physical memory extender
2  * Copyright (C) 2015 M. Imgrund, A. Arth
3  * mimgrund (at) mpifr-bonn.mpg.de
4  * arth (at) usm.uni-muenchen.de
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  */
19 
20 #include "managedSwap.h"
21 #include "managedMemory.h"
22 
23 namespace rambrain
24 {
25 
26 managedSwap::managedSwap ( global_bytesize size ) : swapSize ( size ), swapUsed ( 0 )
27 {
28 }
29 
31 {
33 }
34 
35 void managedSwap::claimUsageof ( global_bytesize bytes, bool rambytes, bool used )
36 {
37  managedMemory::defaultManager->claimUsageof ( bytes, rambytes, used );
38  if ( !rambytes ) {
39 // if((swapFree<bytes&&used )||swapUsed<bytes&&!used)
40 // throw memoryException("Wrong memory accounting!");
41  swapFree += ( used ? -bytes : bytes );
42  swapUsed += ( used ? bytes : -bytes );
43  }
44 }
45 
47 {
48  printf ( "\n" );
49  while ( totalSwapActionsQueued != 0 ) {
50  checkForAIO();
51  printf ( "waiting for aio to complete on %d objects\r", totalSwapActionsQueued );
52  };
53  printf ( " \r" );
54 }
55 
56 }
57 
virtual bool checkForAIO()
Definition: managedSwap.h:122
static managedMemory * defaultManager
void claimUsageof(global_bytesize bytes, bool rambytes, bool used)
account for memory usage change
Definition: managedSwap.cpp:35
global_bytesize swapUsed
Definition: managedSwap.h:147
uint64_t global_bytesize
Definition: common.h:65
unsigned int totalSwapActionsQueued
Definition: managedSwap.h:149
managedSwap(global_bytesize size)
Definition: managedSwap.cpp:26
void waitForCleanExit()
Function waits for all asynchronous IO to complete. The wait is implemented non-performant as a norma...
Definition: managedSwap.cpp:46
void claimUsageof(global_bytesize bytes, bool rambytes, bool used)
account for memory usage change
global_bytesize swapFree
Definition: managedSwap.h:148