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=-0.3 required=5.0 tests=BAYES_00, REPLYTO_WITHOUT_TO_CC autolearn=no autolearn_force=no version=3.4.4 X-Google-Language: ENGLISH,ASCII-7-bit Path: g2news2.google.com!news1.google.com!border1.nntp.dca.giganews.com!nntp.giganews.com!newsfeed00.sul.t-online.de!t-online.de!news.k-dsl.de!newsfeed-fusi2.netcologne.de!news.netcologne.de!newsfeed-hp2.netcologne.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Date: Fri, 03 Oct 2008 11:18:39 +0200 From: Georg Bauhaus Reply-To: rm.tsoh+bauhaus@maps.futureapps.de User-Agent: Thunderbird 2.0.0.17 (Windows/20080914) MIME-Version: 1.0 Newsgroups: comp.lang.ada Subject: Re: Naming convention to identify functions with side effects References: <5654ee5f-aa9f-4fff-87e0-45854b850f26@y38g2000hsy.googlegroups.com> <29ac62e1-78da-4048-ad95-8f88a29f7d31@z6g2000pre.googlegroups.com> <48e13f14$0$6610$9b4e6d93@newsspool3.arcor-online.net> In-Reply-To: Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Message-ID: <48e5e370$0$6615$9b4e6d93@newsspool3.arcor-online.net> Organization: Arcor NNTP-Posting-Date: 03 Oct 2008 11:18:40 CEST NNTP-Posting-Host: 48f5d9ad.newsspool3.arcor-online.net X-Trace: DXC=SSR6;Kfooa8QbA1[CgMQ00McF=Q^Z^V384Fo<]lROoR18kFejV858aZj3WTXK:h Ole-Hjalmar Kristensen wrote: > How would you implement the lock in youre case? I prefer not to mess > around with semaphores, but use protected objects instead. In that > case keeping the lock across the two calls is not so trivial. In a simple, maybe simplistic way I'd hide the lock. package News26 is subtype URL is String; type Web_Resource is tagged limited private; -- ... Observe the calling protocol, which is -- Load -> Is_Loaded -> Discard function Is_Loaded (Page: Web_Resource) return Boolean; procedure Load (Page: in out Web_Resource; Location: URL); procedure Discard (Page: in out Web_Resource); private protected type Resource is entry Seize; procedure Release; private Busy: Boolean := False; end Resource; type Web_Resource is tagged limited record Lock: Resource; -- ... end record; end News26; Procedure Load will then Seize the Lock. Another scheme could, I think, be using Dmitry's Page_Cache administrating the sequencing of calls by slot-wise locking or some such.