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.3 required=5.0 tests=BAYES_00,INVALID_MSGID autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 103376,e94a7e4f6f888766 X-Google-Attributes: gid103376,public From: "Robert I. Eachus" Subject: Re: Self-referential types Date: 1999/10/19 Message-ID: <380CB50C.2DB70690@mitre.org>#1/1 X-Deja-AN: 538041890 Content-Transfer-Encoding: 7bit References: <7ttb4a$8mq$1@nnrp1.deja.com> <3802f2db_2@news1.prserv.net> <3803B5E3.F96A6DD4@mitre.org> <3803c8bc_2@news1.prserv.net> <3804E7E0.6A0265FB@mitre.org> <38077EB3.E6911567@mitre.org> <38078775.73450564@pwfl.com> <38079D6F.4F7C00FA@mitre.org> <7udsva$m0t$1@nnrp1.deja.com> X-Accept-Language: en Content-Type: text/plain; charset=us-ascii X-Complaints-To: usenet@news.mitre.org X-Trace: top.mitre.org 940356564 16579 129.83.41.77 (19 Oct 1999 18:09:24 GMT) Organization: The MITRE Corporation Mime-Version: 1.0 NNTP-Posting-Date: 19 Oct 1999 18:09:24 GMT Newsgroups: comp.lang.ada Date: 1999-10-19T18:09:24+00:00 List-Id: Robert Dewar wrote: > Ah ha! There it is. The trouble is that the creator may not > think tasking is an issue, but later on a consumer is interested > in task safety. PLEASE PLEASE default your thinking to assume > that tasking *is* an issue, and make thinks task safe by > default. Only introduce (well documented!) thread non-safety > deliberately if there is a VERY good reason for it. Sorry, that was an aside that could be misleading. I was referring to a different issue: The cases where the outer procedure creates one or more tasks. These cases are somewhat harder to deal with because of the rules about masters and when a scope is left. For instance if you move a task out of a procedure, so its entries are visible to other (formerly nested) procedures, then you may have to add explicit code to terminate the tasks at the right point in time. This is why you may want to instantiate a generic package inside the procedure to get the right semantics without kludges. In the cases Robert Dewar is talking about, where tasking is not dealt with in otherwise sharable code, you can often factor the tasking out at a higher level. I often wrap procedures this way: procedure Protected_Foo is begin Lock.Seize ; Foo; Lock.Release; end; -- add parmeters to taste. This provides both tasking and non-tasking safe versions. It will work correctly even if Foo is recursive. The other way to deal with potential tasking is to pass all shared data in one or more explicit parameters. This way the caller can do anything necessary at his level. The random number packages in Ada are a result of this type of thinking. Since they pass a generator object around, it is up to the user in a tasking environment to decide which tasks should share generators and how. -- Robert I. Eachus with Standard_Disclaimer; use Standard_Disclaimer; function Message (Text: in Clever_Ideas) return Better_Ideas is...