Thrill  0.1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
memory_file Class Referencefinal

Detailed Description

Implementation of file based on new[] and memcpy.

Definition at line 29 of file memory_file.hpp.

+ Inheritance diagram for memory_file:
+ Collaboration diagram for memory_file:

#include <memory_file.hpp>

Public Member Functions

 memory_file (int queue_id=DEFAULT_QUEUE, int allocator_id=NO_ALLOCATOR, unsigned int device_id=DEFAULT_DEVICE_ID)
 constructs file object. More...
 ~memory_file ()
void discard (offset_type offset, offset_type size) final
const char * io_type () const final
void lock () final
 Locks file for reading and writing (acquires a lock in the file system). More...
void serve (void *buffer, offset_type offset, size_type bytes, request::read_or_write op) final
void set_size (offset_type newsize) final
offset_type size () final
- Public Member Functions inherited from disk_queued_file
 disk_queued_file (int queue_id, int allocator_id)
request_ptr aread (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler()) override
request_ptr awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler()) override
int get_allocator_id () const override
 Returns the file's parallel disk block allocator number. More...
int get_queue_id () const override
- Public Member Functions inherited from file
 file (unsigned int device_id=DEFAULT_DEVICE_ID, file_stats *file_stats=nullptr)
 Construct a new file, usually called by a subclass. More...
 file (const file &)=delete
 non-copyable: delete copy-constructor More...
 file (file &&)=default
 move-constructor: default More...
virtual ~file ()
void add_request_ref ()
 increment referenced requests More...
virtual void close_remove ()
 close and remove file More...
void delete_request_ref ()
 decrement referenced requests More...
virtual void export_files (offset_type offset, offset_type length, std::string prefix)
unsigned int get_device_id () const
 Returns the file's physical device id. More...
file_statsget_file_stats () const
size_t get_request_nref ()
 return number of referenced requests More...
bool need_alignment () const
 Returns need_alignment_. More...
fileoperator= (const file &)=delete
 non-copyable: delete assignment operator More...
fileoperator= (file &&)=default
 move-assignment operator: default More...
- Public Member Functions inherited from ReferenceCounter
 ReferenceCounter () noexcept
 new objects have zero reference count More...
 ReferenceCounter (const ReferenceCounter &) noexcept
 coping still creates a new object with zero reference count More...
 ~ReferenceCounter ()
bool dec_reference () const noexcept
 Call whenever resetting (i.e. More...
void inc_reference () const noexcept
 Call whenever setting a pointer to the object. More...
ReferenceCounteroperator= (const ReferenceCounter &) noexcept
 assignment operator, leaves pointers unchanged More...
size_t reference_count () const noexcept
 Return the number of references to this object (for debugging) More...
bool unique () const noexcept
 Test if the ReferenceCounter is referenced by only one CountingPtr. More...

Private Attributes

std::mutex mutex_
 sequentialize function calls More...
char * ptr_
 pointer to memory area of "file" More...
offset_type size_
 size of memory area More...

Additional Inherited Members

- Public Types inherited from file
using offset_type = request::offset_type
 the offset of a request, also the size of the file More...
enum  open_mode {
  RDONLY = 1, WRONLY = 2, RDWR = 4, CREAT = 8,
  DIRECT = 16, TRUNC = 32, SYNC = 64, NO_LOCK = 128,
using size_type = request::size_type
 the size of a request More...
- Static Public Member Functions inherited from file
static int unlink (const char *path)
 unlink path from filesystem More...
static int truncate (const char *path, external_size_type length)
- Static Public Attributes inherited from file
static const unsigned int DEFAULT_DEVICE_ID = std::numeric_limits<unsigned int>::max()
static const int DEFAULT_LINUXAIO_QUEUE = -2
static const int DEFAULT_QUEUE = -1
static const int NO_ALLOCATOR = -1
- Protected Attributes inherited from file
unsigned int device_id_
bool need_alignment_ = false
 Flag whether read/write operations REQUIRE alignment. More...
tlx::reference_counter request_ref_
 count the number of requests referencing this file More...

Constructor & Destructor Documentation

memory_file ( int  queue_id = DEFAULT_QUEUE,
int  allocator_id = NO_ALLOCATOR,
unsigned int  device_id = DEFAULT_DEVICE_ID 

constructs file object.

Definition at line 42 of file memory_file.hpp.

Definition at line 48 of file memory_file.cpp.

References free(), and memory_file::ptr_.

Member Function Documentation

void discard ( offset_type  offset,
offset_type  size 

Discard a region of the file (mark it unused). Some specialized file types may need to know freed regions

Reimplemented from file.

Definition at line 73 of file memory_file.cpp.

References foxxll::BlockAlignment, free(), memory_file::lock(), LOG1, malloc(), max(), memory_file::mutex_, memory_file::ptr_, memory_file::size(), and tlx::unused().

const char * io_type ( ) const

Identifies the type of I/O implementation.

pointer to null terminated string of characters, containing the name of I/O implementation

Implements file.

Definition at line 43 of file memory_file.cpp.

void lock ( )

Locks file for reading and writing (acquires a lock in the file system).

Implements file.

Definition at line 54 of file memory_file.cpp.

Referenced by foxxll::create_file(), memory_file::discard(), memory_file::serve(), and memory_file::set_size().

void serve ( void *  buffer,
offset_type  offset,
size_type  bytes,
request::read_or_write  op 
void set_size ( offset_type  newsize)

Changes the size of the file.

newsizenew file size

Implements file.

Definition at line 64 of file memory_file.cpp.

References memory_file::lock(), max(), memory_file::mutex_, memory_file::ptr_, realloc(), and memory_file::size_.

file::offset_type size ( )

Returns size of the file.

file size in bytes

Implements file.

Definition at line 59 of file memory_file.cpp.

References memory_file::size_.

Referenced by memory_file::discard().

Member Data Documentation

std::mutex mutex_

sequentialize function calls

Definition at line 38 of file memory_file.hpp.

Referenced by memory_file::discard(), memory_file::serve(), and memory_file::set_size().

char* ptr_

pointer to memory area of "file"

Definition at line 32 of file memory_file.hpp.

Referenced by memory_file::discard(), memory_file::serve(), memory_file::set_size(), and memory_file::~memory_file().

offset_type size_

size of memory area

Definition at line 35 of file memory_file.hpp.

Referenced by memory_file::set_size(), and memory_file::size().

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