LLFIO  v2.00
utils.hpp File Reference

Provides namespace utils. More...

#include "config.hpp"
#include "quickcpplib/algorithm/string.hpp"

Classes

struct  llfio_v2_xxx::utils::process_memory_usage
 Memory usage statistics for a process. More...
 
struct  llfio_v2_xxx::utils::process_cpu_usage
 CPU usage statistics for a process. More...
 
class  llfio_v2_xxx::utils::page_allocator< T >
 An STL allocator which allocates large TLB page memory. More...
 
struct  llfio_v2_xxx::utils::page_allocator< T >::rebind< U >
 
class  llfio_v2_xxx::utils::page_allocator< void >
 
struct  llfio_v2_xxx::utils::page_allocator< void >::rebind
 

Namespaces

 llfio_v2_xxx
 The LLFIO namespace.
 
 llfio_v2_xxx::utils
 Utility routines often useful when using LLFIO.
 

Functions

size_t llfio_v2_xxx::utils::page_size () noexcept
 Returns the smallest page size of this architecture which is useful for calculating direct i/o multiples. More...
 
template<class T >
llfio_v2_xxx::utils::round_down_to_page_size (T i, size_t pagesize) noexcept
 Round a value to its next lowest page size multiple.
 
template<class T >
llfio_v2_xxx::utils::round_up_to_page_size (T i, size_t pagesize) noexcept
 Round a value to its next highest page size multiple.
 
template<class T , typename = decltype( std::declval<T>().data() ), typename = decltype( std::declval<T>().size() )>
llfio_v2_xxx::utils::round_to_page_size_larger (T i, size_t pagesize) noexcept
 Round a pair of a pointer and a size_t to their nearest page size multiples. The pointer will be rounded down, the size_t upwards.
 
template<class T , typename = decltype( std::declval<T>().data() ), typename = decltype( std::declval<T>().size() )>
llfio_v2_xxx::utils::round_to_page_size_smaller (T i, size_t pagesize) noexcept
 Round a pair of a pointer and a size_t to their nearest page size multiples. The pointer will be rounded upwards, the size_t downwards.
 
template<class A , class B >
std::pair< A, B > llfio_v2_xxx::utils::round_to_page_size_larger (std::pair< A, B > i, size_t pagesize) noexcept
 Round a pair of values to their nearest page size multiples. The first will be rounded down, the second upwards.
 
template<class A , class B >
std::pair< A, B > llfio_v2_xxx::utils::round_to_page_size_smaller (std::pair< A, B > i, size_t pagesize) noexcept
 Round a pair of values to their nearest page size multiples. The first will be rounded upwards, the second downwards.
 
const std::vector< size_t > & llfio_v2_xxx::utils::page_sizes (bool only_actually_available=true)
 Returns the page sizes of this architecture which is useful for calculating direct i/o multiples. More...
 
size_t llfio_v2_xxx::utils::file_buffer_default_size ()
 Returns a reasonable default size for page_allocator, typically the closest page size from page_sizes() to 1Mb. More...
 
void llfio_v2_xxx::utils::random_fill (char *buffer, size_t bytes) noexcept
 Fills the buffer supplied with cryptographically strong randomness. Uses the OS kernel API. More...
 
std::string llfio_v2_xxx::utils::random_string (size_t randomlen)
 Returns a cryptographically random string capable of being used as a filename. Essentially random_fill() + to_hex_string(). More...
 
result< void > llfio_v2_xxx::utils::flush_modified_data () noexcept
 Tries to flush all modified data to the physical device.
 
result< void > llfio_v2_xxx::utils::drop_filesystem_cache () noexcept
 Tries to flush all modified data to the physical device, and then drop the OS filesystem cache, thus making all future reads come from the physical device. Currently only implemented for Microsoft Windows and Linux. More...
 
bool llfio_v2_xxx::utils::running_under_wsl () noexcept
 Returns true if this POSIX is running under Microsoft's Subsystem for Linux.
 
result< process_memory_usage > llfio_v2_xxx::utils::current_process_memory_usage (process_memory_usage::want want=process_memory_usage::want::this_process) noexcept
 Retrieve the current memory usage statistics for this process. More...
 
result< process_cpu_usage > llfio_v2_xxx::utils::current_process_cpu_usage () noexcept
 Retrieve the current CPU usage statistics for this system and this process. These are unsigned counters which always increment, and so may eventually wrap. More...
 
large_page_allocation llfio_v2_xxx::utils::detail::calculate_large_page_allocation (size_t bytes)
 
large_page_allocation llfio_v2_xxx::utils::detail::allocate_large_pages (size_t bytes)
 
void llfio_v2_xxx::utils::detail::deallocate_large_pages (void *p, size_t bytes)
 
template<class T , class U >
bool llfio_v2_xxx::utils::operator== (const page_allocator< T > &, const page_allocator< U > &) noexcept
 

Detailed Description

Provides namespace utils.