Windows System Software -- Consulting, Training, Development -- Unique Expertise, Guaranteed Results

Before Posting... Please check out the Community Guidelines in the
Announcements and Administration Category, below.

Re: RE: RE: RE: Re: [BULK] Re: Modern C++ Features in Kernel Mode Drivers

Jeremy_HurrenJeremy_Hurren Posts: 13
To me this is one of the beauties of the STL code. You still have access
to the lock itself, and if you need to acquire and release it multiple
times, you are free to do so without any extra work. But in the case
that is most likely, where you acquire and release once, the lock_guard
protects you from ever forgetting to do the right thing.

It helps to protect you from your own mistakes most of the time, and
still gives you the flexibility to step outside that model when you need
to do something more complex. I think the maxim of "make it easy to do
the right thing and hard to do the wrong thing" can really help code
become more reliable and easier to maintain.


On 7/9/2018 10:10 AM, xxxxx@garlic.com wrote:
> Yeah, it is exactly like auto ptr in previous version of C++. You will have to specifically ask to get a reference, IIRc.
>
> -pro
>
>> On Jul 9, 2018, at 9:07 AM, xxxxx@hotmail.com <xxxxx@lists.osr.com> wrote:
>>
>>> But with judicious appropriate comments, all should be well, and your chances
>>> of leaving the function's scope without releasing the lock are zero.
>> True, but consider the scenario when you may have to release the lock and subsequently re-acquire it
>> in some cases. Apparently, you must be able to find a workaround by messing around with scopes and loops, but imagine how ugly it is going to look. As long as you to things in C-like fashion and treat a spinlock as a variable, rather than an object, you task is just straightforward
>>
>>
>>
>> Anton Bassov
>>
>> ---
>> NTDEV is sponsored by OSR
>>
>> Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev>;
>>
>> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
>> Details at <http://www.osr.com/seminars>;
>>
>> To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>;
>
> ---
> NTDEV is sponsored by OSR
>
> Visit the list online at: <http://www.osronline.com/showlists.cfm?list=ntdev>;
>
> MONTHLY seminars on crash dump analysis, WDF, Windows internals and software drivers!
> Details at <http://www.osr.com/seminars>;
>
> To unsubscribe, visit the List Server section of OSR Online at <http://www.osronline.com/page.cfm?name=ListServer>;
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!