Small buffers
A billing service’s invoicing job reads an invoice’s line-item amounts, in cents, from stdin and sends them in batches of three over a bounded channel to a pricing worker, which sends each batch’s subtotal back over a second channel. The job prints the invoice total. Go and Rust use their standard channels; C++ has none, so the C++ program declares a small Channel class. A watchdog prints stalled if the job has not completed within 3 seconds; it measures a whole-job deadline, not lack of progress. The pricing worker models summation and session finalization with native sleeps; it calls no billing service. Inputs are integer cents with individual values and totals within signed 32-bit range. Easy/Medium use at most 60 items in this profile; Hard uses at most 600. The supplied reporter reads the pricing-session completion receipt after run returns; keep that check when repairing run.
What needs to change
Both channels hold at most two messages. Keep capacity 2, finish every invoice in the declared profile, and report only after the pricing session’s finalization is complete. The supplied pricer closes its data channel before finalizing; its completion receipt is separate.
Reproduce
- Run the program with the sample stdin (60 line items) and compare the report with capacity 2.
Acceptance criteria
Your review marks · Saved in this browser. Test acceptance is tracked separately.
Notes
Review run. capacity is 2 for both channels.
The watchdog prints stalled if run misses a 3-second completion deadline; a delay is not by itself a deadlock proof.
pricer is supplied.