Skip to content

Commit

Permalink
Optional debugging output for AbstractIOHandlerImpl::flush()
Browse files Browse the repository at this point in the history
  • Loading branch information
franzpoeschel committed Aug 10, 2023
1 parent 15feda4 commit 4e1535b
Show file tree
Hide file tree
Showing 2 changed files with 340 additions and 188 deletions.
189 changes: 1 addition & 188 deletions include/openPMD/IO/AbstractIOHandlerImpl.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@
#include "openPMD/auxiliary/DerefDynamicCast.hpp"

#include <future>
#include <iostream>

namespace openPMD
{
Expand All @@ -41,193 +40,7 @@ class AbstractIOHandlerImpl

virtual ~AbstractIOHandlerImpl() = default;

std::future<void> flush()
{
using namespace auxiliary;

while (!(*m_handler).m_work.empty())
{
IOTask &i = (*m_handler).m_work.front();
try
{
switch (i.operation)
{
using O = Operation;
case O::CREATE_FILE:
createFile(
i.writable,
deref_dynamic_cast<Parameter<Operation::CREATE_FILE> >(
i.parameter.get()));
break;
case O::CHECK_FILE:
checkFile(
i.writable,
deref_dynamic_cast<Parameter<Operation::CHECK_FILE> >(
i.parameter.get()));
break;
case O::CREATE_PATH:
createPath(
i.writable,
deref_dynamic_cast<Parameter<O::CREATE_PATH> >(
i.parameter.get()));
break;
case O::CREATE_DATASET:
createDataset(
i.writable,
deref_dynamic_cast<Parameter<O::CREATE_DATASET> >(
i.parameter.get()));
break;
case O::EXTEND_DATASET:
extendDataset(
i.writable,
deref_dynamic_cast<Parameter<O::EXTEND_DATASET> >(
i.parameter.get()));
break;
case O::OPEN_FILE:
openFile(
i.writable,
deref_dynamic_cast<Parameter<O::OPEN_FILE> >(
i.parameter.get()));
break;
case O::CLOSE_FILE:
closeFile(
i.writable,
deref_dynamic_cast<Parameter<O::CLOSE_FILE> >(
i.parameter.get()));
break;
case O::OPEN_PATH:
openPath(
i.writable,
deref_dynamic_cast<Parameter<O::OPEN_PATH> >(
i.parameter.get()));
break;
case O::CLOSE_PATH:
closePath(
i.writable,
deref_dynamic_cast<Parameter<O::CLOSE_PATH> >(
i.parameter.get()));
break;
case O::OPEN_DATASET:
openDataset(
i.writable,
deref_dynamic_cast<Parameter<O::OPEN_DATASET> >(
i.parameter.get()));
break;
case O::DELETE_FILE:
deleteFile(
i.writable,
deref_dynamic_cast<Parameter<O::DELETE_FILE> >(
i.parameter.get()));
break;
case O::DELETE_PATH:
deletePath(
i.writable,
deref_dynamic_cast<Parameter<O::DELETE_PATH> >(
i.parameter.get()));
break;
case O::DELETE_DATASET:
deleteDataset(
i.writable,
deref_dynamic_cast<Parameter<O::DELETE_DATASET> >(
i.parameter.get()));
break;
case O::DELETE_ATT:
deleteAttribute(
i.writable,
deref_dynamic_cast<Parameter<O::DELETE_ATT> >(
i.parameter.get()));
break;
case O::WRITE_DATASET:
writeDataset(
i.writable,
deref_dynamic_cast<Parameter<O::WRITE_DATASET> >(
i.parameter.get()));
break;
case O::WRITE_ATT:
writeAttribute(
i.writable,
deref_dynamic_cast<Parameter<O::WRITE_ATT> >(
i.parameter.get()));
break;
case O::READ_DATASET:
readDataset(
i.writable,
deref_dynamic_cast<Parameter<O::READ_DATASET> >(
i.parameter.get()));
break;
case O::GET_BUFFER_VIEW:
getBufferView(
i.writable,
deref_dynamic_cast<Parameter<O::GET_BUFFER_VIEW> >(
i.parameter.get()));
break;
case O::READ_ATT:
readAttribute(
i.writable,
deref_dynamic_cast<Parameter<O::READ_ATT> >(
i.parameter.get()));
break;
case O::LIST_PATHS:
listPaths(
i.writable,
deref_dynamic_cast<Parameter<O::LIST_PATHS> >(
i.parameter.get()));
break;
case O::LIST_DATASETS:
listDatasets(
i.writable,
deref_dynamic_cast<Parameter<O::LIST_DATASETS> >(
i.parameter.get()));
break;
case O::LIST_ATTS:
listAttributes(
i.writable,
deref_dynamic_cast<Parameter<O::LIST_ATTS> >(
i.parameter.get()));
break;
case O::ADVANCE:
advance(
i.writable,
deref_dynamic_cast<Parameter<O::ADVANCE> >(
i.parameter.get()));
break;
case O::AVAILABLE_CHUNKS:
availableChunks(
i.writable,
deref_dynamic_cast<Parameter<O::AVAILABLE_CHUNKS> >(
i.parameter.get()));
break;
case O::KEEP_SYNCHRONOUS:
keepSynchronous(
i.writable,
deref_dynamic_cast<Parameter<O::KEEP_SYNCHRONOUS> >(
i.parameter.get()));
break;
case O::DEREGISTER:
deregister(
i.writable,
deref_dynamic_cast<Parameter<O::DEREGISTER> >(
i.parameter.get()));
break;
}
}
catch (...)
{
std::cerr << "[AbstractIOHandlerImpl] IO Task "
<< internal::operationAsString(i.operation)
<< " failed with exception. Clearing IO queue and "
"passing on the exception."
<< std::endl;
while (!m_handler->m_work.empty())
{
m_handler->m_work.pop();
}
throw;
}
(*m_handler).m_work.pop();
}
return std::future<void>();
}
std::future<void> flush();

/**
* Close the file corresponding with the writable and release file handles.
Expand Down
Loading

0 comments on commit 4e1535b

Please sign in to comment.