From mboxrd@z Thu Jan 1 00:00:00 1970 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) on polar.synack.me X-Spam-Level: X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00 autolearn=unavailable autolearn_force=no version=3.4.4 Path: eternal-september.org!reader01.eternal-september.org!reader02.eternal-september.org!news.eternal-september.org!news.eternal-september.org!.POSTED!not-for-mail From: "Jeffrey R. Carter" Newsgroups: comp.lang.ada Subject: Re: tasking design considerations Date: Fri, 20 Jan 2017 17:01:58 +0100 Organization: Also freenews.netfront.net; news.tornevall.net; news.eternal-september.org Message-ID: References: <396469b6-6efe-49e7-914b-9226637e031e@googlegroups.com> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Fri, 20 Jan 2017 16:00:20 -0000 (UTC) Injection-Info: mx02.eternal-september.org; posting-host="d21b5bdcd169b790810d9544b9239b82"; logging-data="10114"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX1+sUd/t1Q0UEdQ/2L7osvKN7NOEGRB0ja8=" User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.6.0 In-Reply-To: <396469b6-6efe-49e7-914b-9226637e031e@googlegroups.com> Cancel-Lock: sha1:cLq+HVVhPmUwUpM89V9OAihnJyU= Xref: news.eternal-september.org comp.lang.ada:33105 Date: 2017-01-20T17:01:58+01:00 List-Id: On 01/20/2017 09:07 AM, rrr.eee.27@gmail.com wrote: > > For the ease of reasoning you can assume typically around 0 .. 20 messages > (the maximum certainly << 1000 messages) per time frame T. The cycle time of > T is fixed now to 1 minute, but might go down in the future to 1 second. > Channel B of course has exactly one message per T. The channels are TCP > sockets. Reception of a single complete message in channel A activates > callback function in my program. Callbacks are usually a mechanism used to deal with concurrency in a sequential language. When you have a concurrent language, use of callbacks is usually a poor design. > I want now create a protected object stack. The callbacks from channel A fill > the stack on the top. A cyclic task with a cycle time T reads and removes all > collected messages from the bottom of the stack. The task processes the > messages and sends out the result. This is a queue, not a stack. This seems like a reasonable design. The only question is how task B decides which messages to include for a time frame. If B reads until the queue is empty, it may read msgs that belong in the next time frame. One way to avoid this is to have B obtain the length of the Q and read that many msgs. Another is for B to invoke an operation that gives B a copy of the Q and clears the Q. -- Jeff Carter "Frankie Wolf, wanted by Federal authorities for dancing with a mailman." Take the Money and Run 143