+-spec consume_one(beam_stats:t(), state()) ->
+ state().
+consume_one(#beam_stats{}=BEAMStats, #state{}=State1) ->
+ Q = queue:in(BEAMStats, queue:new()),
+ consume(Q, State1).
+
+-spec consume_all_queued(state()) ->
+ state().
+consume_all_queued(#state{beam_stats_queue=Q}=State1) ->
+ State2 = consume(Q, State1),
+ State2#state{beam_stats_queue = queue:new()}.
+
+-spec consume(queue(), state()) ->
+ state().
+consume(
+ Q,
+ #state
+ { consumer_module = ConsumerModule
+ , consumer_state = ConsumerState
+ }=State
+) ->
+ State#state{consumer_state = ConsumerModule:consume(Q, ConsumerState)}.
+
+-spec enqueue(beam_stats:t(), state()) ->
+ state().
+enqueue(#beam_stats{}=BEAMStats, #state{beam_stats_queue=Q}=State) ->
+ State#state{beam_stats_queue = queue:in(BEAMStats, Q)}.
+
+-spec schedule_first_flush() ->