title: Sequence Diagram: Background Loop
body: <p>I am working on a system (B) that communicates with another system (C) and displays calculated values in a ongoing loop at a terminal (A). (A) asks (B) to report a variable <code>x</code>. (B) does so <strong>without blocking</strong>, so that (B) can continue to deal with (C). Later, (A) asks (B) to also report the variable <code>y</code>, which will served by (B) in the same manner.</p>
  <p>For documentation, I need to create a UML sequence diagram (using <code>plantuml</code>) describing the process. My trouble now is how to model it properly. The communication between (B) and (C) goes on <strong>even though the loop has not finished</strong>. But how do I model that correctly?</p>
  <p>Here's option 1, just using a asynchronous reply in the loop:</p>
  <pre><code>@startuml
  A -&gt;&gt; B: report x
  loop
      B --&gt;&gt; A: x
  end loop
  B -&gt; C: foo
  C --&gt; B: bar
  A -&gt;&gt; B: report y
  loop
      B --&gt;&gt; A: y
  end loop
  B -&gt; C: qux
  C --&gt; B: baz
  @enduml
  </code></pre>
  <p><a href="https://i.stack.imgur.com/Yj0ux.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Yj0ux.png" alt="enter image description here" /></a></p>
  <p>Option 2 works with a condition that becomes true later in the process:</p>
  <pre><code>@startuml
  A -&gt;&gt; B: report x
  loop until reporting x ends
      B --&gt;&gt; A: x
  end loop
  B -&gt; C: foo
  C --&gt; B: bar
  A -&gt;&gt; B: report y
  loop until reporting y ends
      B --&gt;&gt; A: y
  end loop
  B -&gt; C: qux
  C --&gt; B: baz
  B --&gt;&gt; A: end reporting x
  B --&gt;&gt; A: end reporting y
  @enduml
  </code></pre>
  <p><a href="https://i.stack.imgur.com/aRZ5P.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aRZ5P.png" alt="enter image description here" /></a></p>
  <p>Option 2 is more explicit. But does any of the two options denote the process at hand correctly?</p>