From: "Jeffrey R. Carter" <spam.jrcarter.not@spam.not.acm.org>
Subject: Re: tasking design considerations
Date: Fri, 20 Jan 2017 17:01:58 +0100
Date: 2017-01-20T17:01:58+01:00 [thread overview]
Message-ID: <o5tc6k$9s2$1@dont-email.me> (raw)
In-Reply-To: <396469b6-6efe-49e7-914b-9226637e031e@googlegroups.com>
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
prev parent reply other threads:[~2017-01-20 16:01 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-01-20 8:07 tasking design considerations rrr.eee.27
2017-01-20 8:29 ` Björn Lundin
2017-01-20 8:42 ` Dmitry A. Kazakov
2017-01-20 12:32 ` rrr.eee.27
2017-01-20 14:11 ` Dmitry A. Kazakov
2017-01-20 16:01 ` Jeffrey R. Carter [this message]
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox