|
| File (const boost::filesystem::path &filename_, FileAccess type_, const std::function< void()> &closeRequestCallback_=std::function< void()>(), const std::function< void()> &refreshCallback_=std::function< void()>()) |
|
| ~File () override |
| Closes the HDF5 file.
|
|
void | enableSWMR () override |
|
void | refresh () override |
| Refresh the dataset of a reader. More...
|
|
void | requestFlush () |
|
void | flushIfRequested () |
|
template<class T > |
Container< Object, GroupBase >::Creator< T > | createChildObject (const std::string &path) |
|
template<class T > |
T * | openChildObject (const std::string &path) |
|
Object * | openChildObject (const std::string &name_, ElementType *objectType=nullptr, hid_t *type=nullptr) |
|
std::list< std::string > | getChildObjectNames () |
|
template<class T > |
Creator< T > | createChildAttribute (const std::string &path) |
|
template<class T > |
T * | openChildAttribute (const std::string &path) |
|
Attribute * | openChildAttribute (const std::string &name_, ElementType *attributeType=nullptr, hid_t *type=nullptr) |
|
std::set< std::string > | getChildAttributeNames () |
|
bool | hasChildAttribute (const std::string &name_) |
|
GroupBase * | getParent () |
|
File * | getFile () |
|
std::string | getPath () |
|
hid_t | getID () |
| Note: use the returned hid_t only temporarily since it may get invalid, at least when File::enableSWMR is called.
|
|
std::string | getName () |
|
|
static int | getDefaultCompression () |
|
static void | setDefaultCompression (int comp) |
|
static int | getDefaultChunkSize () |
|
static void | setDefaultChunkSize (int chunk) |
|
static int | getDefaultCacheSize () |
|
static void | setDefaultCacheSize (int cache) |
|
static void | dumpSharedMemory (const boost::filesystem::path &filename) |
|
static void | removeSharedMemory (const boost::filesystem::path &filename) |
| Internal helper function which removes the shared memory associated with filename, !!!EVEN if other process still use it!!!
|
|
|
enum class | WriterState { none
, writeRequest
, active
, swmr
} |
| A writer can be in the following state:
|
|
|
void | close () override |
|
void | openReader () |
| Helper function to open the file as a reader.
|
|
void | closeReader () |
| Helper function to close the file as a reader.
|
|
void | openWriter () |
| Helper function to open the file as a writer.
|
|
void | closeWriter () |
| Helper function to close the file as a writer.
|
|
void | wait (Internal::ScopedLock &lock, std::string_view blockingMsg, const std::function< bool()> &pred) |
|
void | stillAlivePing () |
|
void | listenForRequest () |
| The worker function for the thread listenForRequestThread.
|
|
void | initProcessInfo () |
| Write process information of this process to the shared memory.
|
|
void | deinitProcessInfo () |
| Remove process information of this process from the shared memory.
|
|
void | openOrCreateShm () |
| open or create the shared memory atomically (process with using file lock)
|
|
|
static std::string | createShmName (const boost::filesystem::path &filename) |
| transform filename to a valid boost interprocess name.
|
|
|
const boost::filesystem::path | filename |
| The name of the file.
|
|
const FileAccess | type |
| Flag if this instance is a writer or reader.
|
|
const std::function< void()> | closeRequestCallback |
| This callback is called when a writer requested a close of all readers.
|
|
const std::function< void()> | refreshCallback |
| This callback is called when a writer has flushed.
|
|
std::string | shmName |
| Name of the shared memory. More...
|
|
const boost::uuids::uuid | processUUID |
|
Internal::SharedMemory | shm |
|
boost::interprocess::mapped_region | region |
|
SharedMemObject * | sharedData {nullptr} |
| Pointer to the shared memory object.
|
|
bool | flushRequested { false } |
| True if this reader has requested a flush.
|
|
WriterState | lastWriterState { WriterState::none } |
| The last wrtierState known by this object.
|
|
boost::thread | stillAlivePingThread |
|
std::thread | listenForRequestThread |
|
bool | exitThread { false } |
| Flag which is set to true to enforce the thread to exit (on the next condition notify signal)
|
|
|
static int | defaultCompression =1 |
|
static int | defaultChunkSize =100 |
|
static int | defaultCacheSize =100 |
|
static constexpr size_t | MAXREADERS { 100 } |
| the maximal number of readers which can access the file simultanously
|
|
static constexpr size_t | MAXWRITERS { 10 } |
| the maximal number of writers. Just need since only a fixed amount of readers+writers can wait for the ConditionVariable
|
|
|
class | Internal::ScopedLock |
|
|
| GroupBase (int dummy, GroupBase *parent_, const std::string &name_) |
|
| GroupBase (GroupBase *parent_, const std::string &name_) |
|
void | close () override |
|
void | refresh () override |
|
void | flush () override |
|
void | enableSWMR () override |
|
Dataset * | openChildDataset (const std::string &name_, ElementType *objectType, hid_t *type) |
|
GroupBase * | getFileAsGroup () |
|
| Object (GroupBase *parent_, const std::string &name_) |
|
void | close () override |
|
void | refresh () override |
|
void | flush () override |
|
void | enableSWMR () override |
|
Object * | getFileAsObject () |
|
Object * | getAttrParent (const std::string &path, size_t pos) |
|
| Element (std::string name_) |
|
virtual void | close () |
|
virtual void | refresh () |
|
virtual void | flush () |
|
virtual void | enableSWMR () |
|
void | close () |
|
void | refresh () |
|
void | flush () |
|
void | enableSWMR () |
|
Creator< T > | createChild (const std::string &name_) |
|
T * | openChild (const std::string &name_) |
|
void | close () |
|
void | refresh () |
|
void | flush () |
|
void | enableSWMR () |
|
Creator< T > | createChild (const std::string &name_) |
|
T * | openChild (const std::string &name_) |
|
GroupBase * | parent |
|
File * | file |
|
ScopedHID | id |
|
std::string | name |
|
std::map< std::string, Attribute * > | childs |
|
std::map< std::string, Object * > | childs |
|
◆ FileAccess
Enumerator |
---|
read | open file for reading
|
write | open file for writing
|
◆ File()
H5::File::File |
( |
const boost::filesystem::path & |
filename_, |
|
|
FileAccess |
type_, |
|
|
const std::function< void()> & |
closeRequestCallback_ = std::function<void()>() , |
|
|
const std::function< void()> & |
refreshCallback_ = std::function<void()>() |
|
) |
| |
Opens the HDF5 file filename_ as a writer or reader dependent on type_. For a reader closeRequestCallback_ should be set! This callback is called if any writer want to write the file this reader also holds. If this callback is called you should close (destruct) this File object in time. After close (destruct) you can immediately reopen the file by constructing a File object (with the same HDF5 file) again. The inter process communication will ensure the the requested writer does its job before you can reopen the file for reading again. For a reader refreshCallback_ should also be set if the reader will call requestFlush. This this callback is called the reader should call refresh(). Note that both callback functions will be called from of a thread created by this constructor.
◆ close()
◆ dumpSharedMemory()
void H5::File::dumpSharedMemory |
( |
const boost::filesystem::path & |
filename | ) |
|
|
static |
Internal helper function which dumps the content of the shared memory associated with filename. !!! Note that the mutex is NOT locked for this operation but the file lock is accquired.
◆ enableSWMR()
void H5::File::enableSWMR |
( |
| ) |
|
|
overridevirtual |
Switch a writer from dataset creation mode to SWMR. After this call no datasets, groups or attributes can be created anymore and attributes are closed! But readers are no longer blocked and can read the file.
Reimplemented from H5::Element.
◆ flushIfRequested()
void H5::File::flushIfRequested |
( |
| ) |
|
Flush the file (the dataset) of a writer if this is requested by a reader. Does nothing if no reader has requested a flush. If a flush happend the reades are notified about the flush.
◆ refresh()
void H5::File::refresh |
( |
| ) |
|
|
overridevirtual |
Refresh the dataset of a reader.
Reimplemented from H5::Element.
◆ requestFlush()
void H5::File::requestFlush |
( |
| ) |
|
Request a flush of the writer. This is not blocking. If the writer has flushed the refreshCallback is called, see constructor.
◆ wait()
void H5::File::wait |
( |
Internal::ScopedLock & |
lock, |
|
|
std::string_view |
blockingMsg, |
|
|
const std::function< bool()> & |
pred |
|
) |
| |
|
private |
Helper function which waits until the condition pred is true. On entry the lock lock is released and re-aquired if waiting ends (the pred() == true). If this call blocks (pred is not already true on entry) then the message blockingMsg is printed (use a empty string to avoid printing)
◆ listenForRequestThread
std::thread H5::File::listenForRequestThread |
|
private |
A thread created for a reader to listen when a new writer process requests a write of has flushed the file. boost thread interruption points does not help here since its not working with ConditionVariable -> hence we implement it ourself using the exitThread flag
◆ region
boost::interprocess::mapped_region H5::File::region |
|
private |
Memory region holding the shared memory map Access to region (and shm) must bu guarded by locking the boost filelock of filename.
◆ shm
Internal::SharedMemory H5::File::shm |
|
private |
Shared memory object holding the shared memory Access to shm (and region) must bu guarded by locking the boost filelock of filename.
◆ shmName
std::string H5::File::shmName |
|
private |
Name of the shared memory.
a globally unique identifier for this process
The documentation for this class was generated from the following files:
- /mbsim-env/hdf5serie/hdf5serie/hdf5serie/file.h
- /mbsim-env/hdf5serie/hdf5serie/hdf5serie/file.cc