Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.c++ > #15325
| From | scott@slp53.sl.home (Scott Lurndal) |
|---|---|
| Subject | Re: Terminology - RAII vs. Scope Guard vs...? |
| Newsgroups | comp.lang.c++ |
| References | (1 earlier) <2afef88f-f05f-4eb7-929b-fb587f674c68@er9g2000vbb.googlegroups.com> <9164b5b9-0424-4acf-9d2f-1344db90b3a7@w5g2000vbv.googlegroups.com> <jm4pi6$kav$1@speranza.aioe.org> <eb5359e9-10a2-419e-b96a-f6a8a44c51f0@v1g2000yqm.googlegroups.com> <jm5b2q$ka$1@speranza.aioe.org> |
| Organization | |
| Organization | UseNetServer - www.usenetserver.com |
| Message-ID | <4eEhr.12102$bk4.9926@news.usenetserver.com> (permalink) |
| Date | 2012-04-12 17:25 +0000 |
Rui Maciel <rui.maciel@gmail.com> writes:
>Noah Roberts wrote:
>
>>> And just to entertain the idea that Joshua Maurice's claim was wrong,
>>> then that would make Bjarne Stroustrup also wrong.[1] If you take the
>>> time to read 14.4.1 from Stroustrup's "The C++ programming language" you
>>> will realize that what's described there is essentially (or, arguably,
>>> exactly) what Joshua Maurice just pointed out.
>>
>> I don't have that book on my shelf at the moment and you don't even
>> bother to paraphrase so I have no idea if I disagree with Bjarne or
>> not.
>>
>> He's not a God you know. All the big mucky mucks make mistakes. I
>> myself have corrected Myers on occasion.
>
>He is not a God. He is the inventor of RAII, apparently. I believe we can
>agree that the inventor of RAII should be expected to know a bit about RAII.
>
While we didn't call it RAII, we used RAII techniques in an operating
system in 1989 (using Cfront 2.1). I'm not sure when BS codified it.
We also used a class, an instance of which was defined as an automatic
stack variable, which was used to clean up a partial fork() when the
fork failed partway through by using the destructor to free any resources
(memory, file descriptor tables, etc) when the fork failed simply by
returning from the fork implementation member function and letting the
destructor for the instance do the cleanup.
scott
//
// This class implements a recovery mechanism for fork failures.
//
class tForkFailure
{
public:
tProc *procp;
tLwp *CrLwp;
KnCap *ChildCap;
int nlwp;
int total_lwp;
int ret;
KnCap *PActUI;
boolean_t rgn;
boolean_t semundo;
boolean_t file;
tForkFailure(tProc *, tLwp *, KnCap *, int, int);
~tForkFailure();
};
//
// Destructor: undo what fork has done upon failure.
//
tForkFailure::~tForkFailure()
{
if (ret == 0) {
return;
}
if (PActUI != NULL) {
procp->Mem.Exit(ChildCap);
}
//
// XXXKYS: the DeleteAll() needs to take
// into account that some of the LWPs
// in the list may be zombies.
//
procp->LwpList.DeleteAll();
if (rgn == B_TRUE) {
procp->Rgn.ShmExit(CrLwp, procp);
}
if (semundo == B_TRUE) {
procp->Undo.SemUnFork();
}
if (file == B_TRUE) {
procp->File.ForkUndo();
}
procp->ProcRlim->rlFree(nlwp + 1);
procp->ProcCred->CrFree(nlwp + 1);
procp->UidQuota.FreeProc(B_TRUE, total_lwp, 1);
}
Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-10 13:47 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Joshua Maurice <joshuamaurice@gmail.com> - 2012-04-10 14:36 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 09:10 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Joshua Maurice <joshuamaurice@gmail.com> - 2012-04-11 12:28 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 13:29 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-12 02:29 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Joshua Maurice <joshuamaurice@gmail.com> - 2012-04-12 14:31 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-12 16:48 -0700
Re: Terminology - RAII vs. Scope Guard vs...? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-13 02:34 +0200
Re: Terminology - RAII vs. Scope Guard vs...? Miles Bader <miles@gnu.org> - 2012-04-13 10:57 +0900
Re: Terminology - RAII vs. Scope Guard vs...? "Alf P. Steinbach" <alf.p.steinbach+usenet@gmail.com> - 2012-04-13 09:52 +0200
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-13 10:48 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Miles Bader <miles@gnu.org> - 2012-04-13 22:18 +0900
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-13 09:21 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2012-04-11 21:36 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 16:07 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Juha Nieminen <nospam@thanks.invalid> - 2012-04-12 06:10 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Gareth Owen <gwowen@gmail.com> - 2012-04-12 18:18 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Juha Nieminen <nospam@thanks.invalid> - 2012-04-13 04:52 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Gareth Owen <gwowen@gmail.com> - 2012-04-13 06:59 +0100
Never using free() or realloc(). Destroying heaps. @Jeff-Relf.Me - 2012-04-13 00:55 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-11 21:28 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-11 13:40 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-12 02:27 +0100
Re: Terminology - RAII vs. Scope Guard vs...? scott@slp53.sl.home (Scott Lurndal) - 2012-04-12 17:25 +0000
Re: Terminology - RAII vs. Scope Guard vs...? Gareth Owen <gwowen@gmail.com> - 2012-04-12 19:21 +0100
Re: Terminology - RAII vs. Scope Guard vs...? Noah Roberts <roberts.noah@gmail.com> - 2012-04-12 16:38 -0700
Re: Terminology - RAII vs. Scope Guard vs...? Rui Maciel <rui.maciel@gmail.com> - 2012-04-13 11:02 +0100
Re: Terminology - RAII vs. Scope Guard vs...? nick_keighley_nospam@hotmail.com - 2012-04-13 00:29 -0700
Re: Terminology - RAII vs. Scope Guard vs...? nick_keighley_nospam@hotmail.com - 2012-04-13 00:14 -0700
csiph-web