C++ PPL make_choice

  • Thread starter Thread starter Zandareus
  • Start date Start date
Z

Zandareus

Guest
t of a story, so I will summarize to the point of interest that is reproducible via the example found on MSDN document

Asynchronous Message Blocks

The reference example is found halfway down the webpage, “choice Class” my problem is with unbounded_buffer

I have modified both single_assignment, and overwrite_buffer, to end execution last by changing 35 and 37 to higher numbers, and the number used for the unbounded_buffer to a lower number, so it completes faster.

Switch(receive(select_one) // seems to consume the message

The receive(selection_one) will correctly identify case 2, that is used with the unbounded_buffer, but it will consume the message in the unbounded_buffer. when reaching Case 2<g class="gr_ gr_47 gr-alert gr_gramm gr_inline_cards gr_run_anim Punctuation multiReplace" data-gr-id="47" id="47">:,</g> and executing receive (half of <g class="gr_ gr_46 gr-alert gr_gramm gr_inline_cards gr_run_anim Grammar only-ins replaceWithoutSep" data-gr-id="46" id="46">fib</g>), the function blocks because there are no messages to receive because the previous receive function removed it. Case 0, and 1 both work because you can execute a receive function as many times as you want without consuming the message.

However, in case 2, it blocks indefinitely, my only solution is to issue a double send, but it seems the example is intended to be able to receive the message after the identifying which message source was selected.

My use case is a bit more complicated than the example, I have several identical agents using the same unbounded buffer as a source, that works fine, until I needed to make a choice(in the pipeline), if I issue a double send, it may deadlock if 2 agents consume each of the input messages, and then block on the 2<sup>nd</sup> receive message. So, the message may get lost because it was consumed in the selector receive

My question is, how do I, receive the message in the unbounded buffer without <g class="gr_ gr_28 gr-alert gr_gramm gr_inline_cards gr_run_anim Style multiReplace" data-gr-id="28" id="28">issuing </g><g class="gr_ gr_28 gr-alert gr_gramm gr_inline_cards gr_disable_anim_appear Style multiReplace" data-gr-id="28" id="28">a</g> double send. Is it possible or is this a flaw in the PPL library


Thank you for any help you can provide




<style></style>

Continue reading...
 
Back
Top