35#ifndef _UTILS_AUTOSYNCFILEFLOW_H_
36#define _UTILS_AUTOSYNCFILEFLOW_H_
59 , name_(StringPrintf(
"AutoSyncFileFlow(%d)", fd_))
72 std::swap(shutdownDone_, n);
82 const uint64_t interval_;
83 const std::string name_;
84 StateFlowTimer timer_{
this};
85 bool shutdown_{
false};
88 Action sleep_and_call_sync()
#define STATE(_fn)
Turns a function name into an argument to be supplied to functions expecting a state.
This class sends a notification in its destructor.
Simple state flow to configure automatic calls to fsync on a single file handle at regular intervals.
AutoSyncFileFlow(Service *service, int sync_fd, uint64_t interval=SEC_TO_NSEC(1))
Constructor.
void shutdown(Notifiable *n)
Requests the discontinuation of automatic calls to fsync.
An object that can schedule itself on an executor to run.
virtual void notify()=0
Generic callback.
Collection of related state machines that pend on incoming messages.
Base class for state machines.
Service * service()
Return a pointer to the service I am bound to.
Action exit()
Terminate current StateFlow activity.
void start_flow(Callback c)
Resets the flow to the specified state and starts it.
Action call_immediately(Callback c)
Imediately call the next state upon return.
Action sleep_and_call(::Timer *timer, long long timeout_nsec, Callback c)
Suspends execution of this control flow for a specified time.
void ensure_triggered()
Triggers the timer if it is not expired yet.
#define ERRNOCHECK(where, x...)
Calls the function x, and if the return value is negative, prints errno as error message to stderr an...
#define HASSERT(x)
Checks that the value of expression x is true, else terminates the current process.
#define SEC_TO_NSEC(_sec)
Convert a second value to a nanosecond value.