PolyFEM
Loading...
Searching...
No Matches
OutputWriter.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <functional>
4#include <memory>
5
6namespace polyfem::io
7{
12 {
13 public:
14 using Job = std::function<void()>;
15 using Prepare = std::function<Job()>;
16
17 explicit OutputWriter(bool asynchronous = true);
19 OutputWriter(const OutputWriter &) = delete;
21
23 void enqueue(const Prepare &prepare);
25 void execute(const Job &compute);
27 void flush();
29 void finish();
30 bool asynchronous() const;
31
32 private:
33 class Impl;
34 std::unique_ptr<Impl> impl_;
35 };
36} // namespace polyfem::io
Ordered output with one pending frame in addition to the active frame.
std::unique_ptr< Impl > impl_
void enqueue(const Prepare &prepare)
Wait for the pending slot, then prepare its owned frame on the caller.
void flush()
Wait for all accepted frames and propagate output failures.
void finish()
Drain accepted frames, stop the worker, and propagate output failures.
std::function< Job()> Prepare
OutputWriter & operator=(const OutputWriter &)=delete
void execute(const Job &compute)
Run simulation work with one thread reserved for asynchronous output.
std::function< void()> Job
OutputWriter(const OutputWriter &)=delete