MayaFlux 0.2.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 97 of file BufferUtils.cpp.

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