From: Ole-Hjalmar Kristensen <ole-hjalmar.kristensen@substitute_employer_here.com>
Subject: Re: Naming convention to identify functions with side effects
Date: 06 Oct 2008 09:24:50 +0200
Date: 2008-10-06T09:24:50+02:00 [thread overview]
Message-ID: <wvbrk5cmgp8d.fsf@sun.com> (raw)
In-Reply-To: 48e5e370$0$6615$9b4e6d93@newsspool3.arcor-online.net
Yes, this works fine as long as all callers respect the calling protocol, but I
have spent countless hours tracking down bugs which come from people
*not* respecting such protocols, so I do not really like such
solutions unless you can guarantee that the resource will be released
sooner or later.
>>>>> "GB" == Georg Bauhaus <rm.tsoh.plus-bug.bauhaus@maps.futureapps.de> writes:
GB> 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.
GB> In a simple, maybe simplistic way I'd hide the lock.
GB> package News26 is
GB> subtype URL is String;
GB> type Web_Resource is tagged limited private;
GB> -- ... Observe the calling protocol, which is
GB> -- Load -> Is_Loaded -> Discard
GB> function Is_Loaded (Page: Web_Resource) return Boolean;
GB> procedure Load (Page: in out Web_Resource; Location: URL);
GB> procedure Discard (Page: in out Web_Resource);
GB> private
GB> protected type Resource is
GB> entry Seize;
GB> procedure Release;
GB> private
GB> Busy: Boolean := False;
GB> end Resource;
GB> type Web_Resource is tagged limited
GB> record
GB> Lock: Resource;
GB> -- ...
GB> end record;
GB> end News26;
GB> Procedure Load will then Seize the Lock.
GB> Another scheme could, I think, be using Dmitry's Page_Cache
GB> administrating the sequencing of calls by slot-wise locking
GB> or some such.
--
C++: The power, elegance and simplicity of a hand grenade.
next prev parent reply other threads:[~2008-10-06 7:24 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-09-29 18:17 Naming convention to identify functions with side effects Hibou57 (Yannick Duchêne)
2008-09-29 18:45 ` Hibou57 (Yannick Duchêne)
2008-09-29 18:55 ` Adam Beneschan
2008-09-29 19:52 ` Dmitry A. Kazakov
2008-09-29 20:48 ` Georg Bauhaus
2008-09-29 21:10 ` Adam Beneschan
2008-09-30 15:17 ` Georg Bauhaus
2008-09-30 17:40 ` Ray Blaak
2008-10-02 12:33 ` Ole-Hjalmar Kristensen
2008-10-03 9:18 ` Georg Bauhaus
2008-10-06 7:24 ` Ole-Hjalmar Kristensen [this message]
2008-10-03 11:51 ` Brian Drummond
2008-10-03 12:28 ` Dmitry A. Kazakov
2008-10-04 12:30 ` Marco
2008-10-04 13:05 ` (see below)
2008-10-04 15:14 ` Gary Scott
2008-10-11 11:32 ` Marco
2008-10-11 14:57 ` Dmitry A. Kazakov
2008-10-11 16:05 ` (see below)
2008-10-11 17:49 ` Georg Bauhaus
2008-10-11 18:42 ` (see below)
2008-10-03 13:15 ` Jeffrey Creem
2008-09-29 20:57 ` Georg Bauhaus
2008-09-29 22:22 ` Dr. Adrian Wrigley
replies disabled
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox