comp.lang.ada
 help / color / mirror / Atom feed
From: Shark8 <onewingedshark@gmail.com>
Subject: Re: Attempting to create file i task
Date: Wed, 17 Mar 2021 08:20:28 -0700 (PDT)	[thread overview]
Message-ID: <82149dfa-91b2-481c-9404-1ca2370c3714n@googlegroups.com> (raw)
In-Reply-To: <6aad7864-7b88-4e73-b4fe-f4cd30673b28n@googlegroups.com>

On Wednesday, March 17, 2021 at 6:39:05 AM UTC-6, reinert wrote:
> Hello, 
> 
> Assume task A starts subsequentially two times sub-sequentially (but not overlapping in time). It creates and closes a file: 
> 
> define 
> my_file : File_Type; 
> begin 
> Create (File => my_file, Mode => Out_File, Name => my_file_name); 
> ..some statements... 
> Close(my_file); 
> end; 
> 
> I now have the strange experience that task A overwrites the file 
> created the first time? Any idea where to look for the error? 
> 
> reinert

What I would do in this situation:
(1) Make a function that opens the file, on the exception where it does not exist it creates the file.
(2) For my own convenience, I would likely wrap the file-type in a controlled object which would close the file on Finalize, and has a "Get_Stream" method.
(3) Combine #1 and #2 so that creating #2's type does #1.
(4) Given the above, adding some debugging information is rather trivial.
(5) Once things are debugged, you can delete the debugging-info and you still have a useful framework for handling files.

      parent reply	other threads:[~2021-03-17 15:20 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-03-17 12:39 Attempting to create file i task reinert
2021-03-17 12:49 ` J-P. Rosen
2021-03-17 14:17   ` reinert
2021-03-17 14:21     ` reinert
2021-03-17 14:34     ` Jeffrey R. Carter
2021-03-17 15:01     ` Dmitry A. Kazakov
2021-03-17 16:19     ` J-P. Rosen
2021-03-17 16:56       ` reinert
2021-03-17 20:13         ` Simon Wright
2021-03-17 14:18   ` AdaMagica
2021-03-17 14:33     ` Jeffrey R. Carter
2021-03-17 14:34     ` reinert
2021-03-17 14:47       ` AdaMagica
2021-03-17 15:37         ` Jeffrey R. Carter
2021-03-17 16:56           ` AdaMagica
2021-03-17 15:20 ` Shark8 [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