16 #ifndef FOXXLL_IO_FILE_HEADER 17 #define FOXXLL_IO_FILE_HEADER 30 #include <foxxll/config.hpp> 36 #if defined(__linux__) 37 #define FOXXLL_CHECK_BLOCK_ALIGNING 95 explicit file(
unsigned int device_id = DEFAULT_DEVICE_ID,
99 :
stats::get_instance()->create_file_stats(device_id))
155 virtual void lock() = 0;
180 TLX_LOG1 <<
"foxxll::file is being deleted while there are still " 181 << nr <<
" (unfinished) requests referencing it";
188 virtual const char *
io_type()
const = 0;
245 static int unlink(
const char* path);
269 #endif // !FOXXLL_IO_FILE_HEADER
virtual void set_size(offset_type newsize)=0
virtual int get_allocator_id() const =0
Returns the file's parallel disk block allocator number.
only reading of the file is allowed
only writing of the file is allowed
uint64_t offset_type
type for offsets within a file
static uint_pair max()
return an uint_pair instance containing the largest value possible
virtual offset_type size()=0
virtual void export_files(offset_type offset, offset_type length, std::string prefix)
static const unsigned int DEFAULT_DEVICE_ID
unsigned int get_device_id() const
Returns the file's physical device id.
virtual const char * io_type() const =0
request::offset_type offset_type
the offset of a request, also the size of the file
file & operator=(const file &)=delete
non-copyable: delete assignment operator
virtual request_ptr awrite(void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler())=0
do not acquire an exclusive lock by default
size_t size_type
type for block transfer sizes
implies DIRECT, fail if opening with DIRECT flag does not work.
virtual request_ptr aread(void *buffer, offset_type pos, size_type bytes, const completion_handler &on_complete=completion_handler())=0
void delete_request_ref()
decrement referenced requests
virtual int get_queue_id() const =0
bool dec_reference() const noexcept
Call whenever resetting (i.e.
tlx::delegate< void(request *r, bool success)> completion_handler
completion handler
request::size_type size_type
the size of a request
virtual void lock()=0
Locks file for reading and writing (acquires a lock in the file system).
virtual void close_remove()
close and remove file
virtual void serve(void *buffer, offset_type offset, size_type bytes, request::read_or_write op)=0
static int truncate(const char *path, external_size_type length)
size_t get_request_nref()
return number of referenced requests
size_t reference_count() const noexcept
Return the number of references to this object (for debugging)
static const int DEFAULT_QUEUE
std::basic_string< char, std::char_traits< char >, Allocator< char > > string
string with Manager tracking
tlx::reference_counter request_ref_
count the number of requests referencing this file
High-performance smart pointer used as a wrapping reference counting pointer.
virtual void discard(offset_type offset, offset_type size)
static const size_t bytes
number of bytes in uint_pair
file_stats * get_file_stats() const
void inc_reference() const noexcept
Call whenever setting a pointer to the object.
static const int DEFAULT_LINUXAIO_QUEUE
file(unsigned int device_id=DEFAULT_DEVICE_ID, file_stats *file_stats=nullptr)
Construct a new file, usually called by a subclass.
static const int NO_ALLOCATOR
static int unlink(const char *path)
unlink path from filesystem
bool need_alignment() const
Returns need_alignment_.
bool need_alignment_
Flag whether read/write operations REQUIRE alignment.
once file is opened its length becomes zero
read and write of the file are allowed
open the file with O_SYNC | O_DSYNC | O_RSYNC flags set
uint64_t external_size_type
void add_request_ref()
increment referenced requests
Provides reference counting abilities for use with CountingPtr.