C++ in the kernel

Alfred Perlstein alfred at freebsd.org
Wed Oct 31 10:59:58 PDT 2007


* Jan Grant <jan.grant at 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


More information about the freebsd-arch mailing list