MayaFlux 0.3.0
Digital-First Multimedia Processing Framework
Loading...
Searching...
No Matches

◆ wait_for_snapshot_completion()

bool MayaFlux::Buffers::wait_for_snapshot_completion ( const std::shared_ptr< Nodes::Node > &  node,
uint64_t  active_context_id,
int  max_spins = MAX_SPINS 
)

Wait for an active snapshot context to complete using exponential backoff.

Returns
true if completed, false if timeout

Definition at line 98 of file BufferUtils.cpp.

102{
103 int spin_count = 0;
104
105 while (node->is_in_snapshot_context(active_context_id) && spin_count < max_spins) {
106 if (spin_count < 10) {
107 for (int i = 0; i < (1 << spin_count); ++i) {
108 MF_PAUSE_INSTRUCTION();
109 }
110 } else {
111 std::this_thread::yield();
112 }
113 ++spin_count;
114 }
115
116 if (spin_count >= max_spins) {
117 MF_RT_ERROR(Journal::Component::Buffers, Journal::Context::BufferProcessing,
118 "Timeout waiting for node snapshot to complete. "
119 "Possible deadlock or very long processing time.");
120 return false;
121 }
122
123 return true;
124}
#define MF_RT_ERROR(comp, ctx,...)

References MayaFlux::Journal::BufferProcessing, MayaFlux::Journal::Buffers, and MF_RT_ERROR.

Referenced by extract_multiple_samples(), extract_single_sample(), and update_buffer_with_node_data().

+ Here is the caller graph for this function: