Date: Wed, 31 Oct 2007 10:04:39 -0700 From: Alfred Perlstein <alfred@freebsd.org> To: Jan Grant <jan.grant@bristol.ac.uk> Cc: Poul-Henning Kamp <phk@phk.freebsd.dk>, Garance A Drosehn <gad@FreeBSD.org>, freebsd-arch@FreeBSD.org Subject: Re: C++ in the kernel Message-ID: <20071031170439.GE35925@elvis.mu.org> In-Reply-To: <20071031161042.T41569@tribble.ilrt.bris.ac.uk> References: <20071031153248.4395A5B59@mail.bitblocks.com> <20071031161042.T41569@tribble.ilrt.bris.ac.uk>
next in thread | previous in thread | raw e-mail | index | archive | help
* Jan Grant <jan.grant@bristol.ac.uk> [071031 09:57] wrote:
> On Wed, 31 Oct 2007, Bakul Shah wrote:
>
> > For example what if you can't gain the lock and want
> > to do something else? Two, while C++ gives you a way to
> > solve this problem, it does it in a "clever" way, not an
> > obvious way.
>
> RAII is a very common C++ idiom; that kind of thing'd be obvious to
> anyone who's mired^Wimmersed in C++ on a regular basis.
>
> That's the point here - if this was the language technology already in
> use, then it'd be obvious, and nobody would think much about it. It's
> not, so it looks alien, much like any other alternatives that'll get
> raised along the line of C-plus-stuff look alien. Amongst C++ users with
> taste (and I claim that they do exist) the natural question that'll then
> be asked is, since you can already express this idea in C++ why would
> you adopt a less widespread (or novel) language?
>
> jan
>
> PS. Paint it green.
Hhehehehe....
{
mutex_locker_trylock trylock(&mutex);
if (trylock.success()) {
} else {
}
}
// regardless if it succeeded, lock is now dropped.
I think this might even work:
{
if (mutex_locker_trylock trylock(&mutex).success()) {
} else {
}
}
brb, gonna throw up. :)
--
- Alfred Perlstein
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20071031170439.GE35925>
