Concrete Python  git-339c971
Classes | Public Types | Public Member Functions | Static Public Member Functions
Arena Class Reference

#include <concrete/arena.hpp>

+ Inheritance diagram for Arena:
+ Collaboration diagram for Arena:

List of all members.

Classes

struct  Snapshot

Public Types

enum  { SizeLimit }

Public Member Functions

 Arena () throw ()
 Arena (void *data, size_t size) throw ()
Snapshot snapshot () const throw ()
Allocator::Allocation allocate (size_t size)
void free (unsigned int address, void *data, size_t size) throw ()
void * access (unsigned int address, size_t size)
void * nonthrowing_access (unsigned int address, size_t size) throw ()
void extend_access (unsigned int address, size_t size)
bool nonthrowing_extend_access (unsigned int address, size_t size) throw ()
void defer_access_error (unsigned int address) throw ()
void check_access_error ()

Static Public Member Functions

static ArenaActive () throw ()

Detailed Description

Contiguous heap memory.


Member Enumeration Documentation

anonymous enum
Enumerator:
SizeLimit 

Maximum arena size in bytes.


Constructor & Destructor Documentation

Arena ( ) throw ()

Create an empty arena.

Arena ( void *  data,
size_t  size 
) throw ()

Create an arena out of a snapshot. The created Arena instance takes ownership of the data, which must have been allocated so that it can be passed to std::realloc().

Parameters:
dataof the snapshot; will be stolen
sizeof the snapshot in bytes

Member Function Documentation

void * access ( unsigned int  address,
size_t  size 
)

Get a pointer to an allocated memory block. The pointer is valid until the next allocate() call.

Parameters:
addressof the memory block within the arena
sizeof the memory block
Returns:
borrowed short-term reference
Exceptions:
IntegrityError
Arena & Active ( ) throw () [static]

Get the active instance of the current thread.

Allocator::Allocation allocate ( size_t  size)

Allocate a block of memory.

Parameters:
sizeof the memory block
Exceptions:
AllocationError

Throw an IntegrityError if a previous non-throwing code path has detected one.

Exceptions:
IntegrityError
void defer_access_error ( unsigned int  address) throw ()

Cause the next allocate(), access(), extend_access() or check_access_error() call to fail. For code paths where you can't throw an IntegrityError yourself.

Parameters:
addressof the memory block where you detected an inconsistency
void extend_access ( unsigned int  address,
size_t  size 
)

Extend a memory reference obtained with a preceding access() call (without any allocate() calls in between). This simply verifies the new range.

Parameters:
addresswhich has been already validated
sizeis old_size + extension_size
Exceptions:
IntegrityError
void free ( unsigned int  address,
void *  data,
size_t  size 
) throw ()

Free a block of memory. The data pointer must have been retrieved with a preceding access() or nonthrowing_access() call (without any allocate() calls in between).

Parameters:
addressof the memory block within the arena
datapointer to the memory block
sizeof the memory block
void * nonthrowing_access ( unsigned int  address,
size_t  size 
) throw ()

Get a pointer to an allocated memory block. The pointer is valid until the next allocate() call.

Parameters:
addressof the memory block within the arena
sizeof the memory block
Returns:
borrowed short-term reference or NULL
bool nonthrowing_extend_access ( unsigned int  address,
size_t  size 
) throw ()

Extend a memory reference obtained with a preceding nonthrowing_access() call (without any allocate() calls in between). This simply validates the new range.

Parameters:
addresswhich has been already validated
sizeis old_size + extension_size
Returns:
success
Arena::Snapshot snapshot ( ) const throw ()

Get direct short-term read-only access to the arena memory.