FX::FXProcess_MemLock Class Reference

#include <FXProcess.h>

List of all members.


Detailed Description

Prevents a region from being paged out for the duration of its existence.

This little class for the duration of its existence locks a range of a process' address space into memory, thus preventing it from being paged out. This can be useful when utmost performance is required or more likely to prevent secure data from being leaked. The FX::Secure namespace heap manages one of these automatically.

What you specify to this class at construction and what actually gets locked can vary, not least because locking is done in units of FX::FXProcess::pageSize(). You can determine what pages are locked at any given time using FX::FXProcess::lockedPages(). Nested locks across multiple threads are fine eg;

FXProcess_LockMem h1(ptr, 16384);       // Thread 1
FXProcess_LockMem h2(ptr+4096, 32768);  // Thread 2
delete h1;                              // Thread 1
In the above, the region ptr+4096 to ptr+36864 remains locked.

Warning:
Many operating systems view locking too many pages in memory as a malicious act and so FXRESTRICT the maximum per process. In particular on Windows NT systems it can be a very low amount, perhaps only 200Kb.

Public Member Functions

 FXProcess_MemLock ()
 FXProcess_MemLock (void *startaddr, FXuval length)
 FXProcess_MemLock (const FXProcess_MemLock &o)
FXProcess_MemLockoperator= (const FXProcess_MemLock &o)
void * location () const throw ()
FXuval length () const throw ()

Constructor & Destructor Documentation

FX::FXProcess_MemLock::FXProcess_MemLock (  )  [inline]

Creates a null lock.

FX::FXProcess_MemLock::FXProcess_MemLock ( void *  startaddr,
FXuval  length 
) [inline]

Creates an instance locking the specified region.


Member Function Documentation

void* FX::FXProcess_MemLock::location (  )  const throw () [inline]

Returns the start of the locked region.

FXuval FX::FXProcess_MemLock::length (  )  const throw () [inline]

Returns the length of the locked region.


The documentation for this class was generated from the following file:

(C) 2002-2008 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Jun 13 22:10:02 2008 for TnFOX by doxygen v1.5.6