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!feeder.eternal-september.org!aioe.org!.POSTED.fn3LatRFkm9/xzEj7F2/NQ.user.gioia.aioe.org!not-for-mail From: "Dmitry A. Kazakov" Newsgroups: comp.lang.ada Subject: Re: How to transfer Class-Wide object to a Task ? Date: Tue, 15 Oct 2019 09:21:48 +0200 Organization: Aioe.org NNTP Server Message-ID: References: <5da4cf81$0$20312$426a74cc@news.free.fr> <5da4e182$0$20321$426a74cc@news.free.fr> NNTP-Posting-Host: fn3LatRFkm9/xzEj7F2/NQ.user.gioia.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: Mozilla/5.0 (Windows NT 10.0; WOW64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 X-Notice: Filtered by postfilter v. 0.9.2 Content-Language: en-US Xref: reader01.eternal-september.org comp.lang.ada:57291 Date: 2019-10-15T09:21:48+02:00 List-Id: On 2019-10-14 22:58, William FRANCK wrote: > Here is the multitasking part (simplified) (working, no issue) > for reading the datafile, and writing it back (after some data-process) > > My first intention was : while Writing.Bloc is busy writing on the > output file, Reading.Bloc can take 1 record in advance That is what OS asynchronous I/O does already. But that is aside. > Now I have to insert the class-wide object passing in the Bloc. Stream attributes 'Input and 'Output would do. > As You mentionned, should I use a protected type (FIFO)  instead of 2 // > tasks ? A protected object to synchronize two tasks: Producer -> FIFO -> Consumer Block put <- PO -> Block get when full when empty FIFO does not need interlocking in this scenario. Protected object is only to prevent busy waiting at the ends. Since you are working with streams you can use a storage stream instead of raw FIFO: Producer -> Storage stream -> Consumer Block write when full Block read when empty I still do not understand why you serialize and deserialize insted of copying bytes as they are. -- Regards, Dmitry A. Kazakov http://www.dmitry-kazakov.de