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

Detailed Description

Base for UNIX file system implementations.

Definition at line 32 of file ufs_file_base.hpp.

+ Inheritance diagram for ufs_file_base:
+ Collaboration diagram for ufs_file_base:

#include <ufs_file_base.hpp>

Public Member Functions

 ~ufs_file_base ()
void close_remove () final
 close and remove file More...
const char * io_type () const override
bool is_device () const
 return true if file is special device node More...
void lock () final
 Locks file for reading and writing (acquires a lock in the file system). More...
void set_size (offset_type newsize) final
offset_type size () final
void unlink ()
 unlink file without closing it. More...
- 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 request_ptr aread (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler())=0
virtual request_ptr awrite (void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler())=0
void delete_request_ref ()
 decrement referenced requests More...
virtual void discard (offset_type offset, offset_type size)
virtual void export_files (offset_type offset, offset_type length, std::string prefix)
virtual int get_allocator_id () const =0
 Returns the file's parallel disk block allocator number. More...
unsigned int get_device_id () const
 Returns the file's physical device id. More...
file_statsget_file_stats () const
virtual int get_queue_id () const =0
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...
virtual void serve (void *buffer, offset_type offset, size_type bytes, request::read_or_write op)=0
- 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...

Protected Member Functions

 ufs_file_base (const std::string &filename, int mode)
void _after_open ()
void _set_size (offset_type newsize)
offset_type _size ()
void close ()

Protected Attributes

std::mutex fd_mutex_
int file_des_
const std::string filename_
bool is_device_
 is special device node More...
int mode_
- 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...

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

Constructor & Destructor Documentation

Definition at line 130 of file ufs_file_base.cpp.

References ufs_file_base::close().

Member Function Documentation

void close ( )
void close_remove ( )

close and remove file

Reimplemented from file.

Definition at line 283 of file ufs_file_base.cpp.

References ufs_file_base::close(), ufs_file_base::filename_, ufs_file_base::is_device_, and TLX_LOG1.

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 28 of file ufs_file_base.cpp.

bool is_device ( ) const

return true if file is special device node

Definition at line 310 of file ufs_file_base.cpp.

References ufs_file_base::is_device_.

Referenced by foxxll::create_file().

void lock ( )

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

Implements file.

Definition at line 195 of file ufs_file_base.cpp.

References ufs_file_base::fd_mutex_, ufs_file_base::file_des_, ufs_file_base::filename_, FOXXLL_THROW_ERRNO, ufs_file_base::mode_, and file::RDONLY.

Referenced by ufs_file_base::_after_open(), and foxxll::create_file().

void set_size ( offset_type  newsize)

Changes the size of the file.

newsizenew file size

Implements file.

Definition at line 231 of file ufs_file_base.cpp.

References ufs_file_base::_set_size(), and ufs_file_base::fd_mutex_.

file::offset_type size ( )

Returns size of the file.

file size in bytes

Implements file.

Definition at line 225 of file ufs_file_base.cpp.

References ufs_file_base::_size(), and ufs_file_base::fd_mutex_.

Referenced by foxxll::create_file().

void unlink ( )

unlink file without closing it.

Definition at line 298 of file ufs_file_base.cpp.

References ufs_file_base::file_des_, ufs_file_base::filename_, FOXXLL_THROW_ERRNO, ufs_file_base::is_device_, and TLX_LOG1.

Referenced by foxxll::create_file().

Member Data Documentation

std::mutex fd_mutex_
bool is_device_
int mode_

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