Boost logo

Boost :

From: Vesa Karvonen (vesa.karvonen_at_[hidden])
Date: 2001-07-20 15:24:03

From: "Kevlin Henney" <kevlin_at_[hidden]>
> > From: "Vesa Karvonen" <vesa.karvonen_at_[hidden]>
> >From: "Kevlin Henney" <kevlin_at_[hidden]>
> >> Have you considered using the name 'locker'? This is the one I tend to
> >> use: a locker (the scoped locking object) locks (calls the member
> >> function) a lock (the mutex).
> >
> >I'm not native English, but 'locker' sounds like the thing that you use for
> >storing objects. ;-)
> Quite correct, this is one of its meanings. Although it is worth
> pointing out that "locker" has fewer meanings in English than either
> "lock" or "guard" :->
> However, the analogy is not lost with this alternative meaning: a locker
> is an enclosed space that may be locked and unlocked ;-)

hmn... That sounds more like the concept of a mutex rather than something that
locks and unlocks a mutex automatically. [Of course, that is not the locker
you intended.]

> >Anyway, this and related idioms have many names such as:
> >- 'guard' (
> This naming convention is somewhat older than Andrei's stuff :-) You
> will find it commonly used across much of the literature and in much
> code.

Yes indeed. The link was just an example (the one that I recalled first).

> >- 'proxy' (GoF)
> Simply inaccurate if the object does not support forwarding semantics
> :-(

Well, I added "related idioms", but admittedly the intent of proxy is somewhat
different. The locked template I briefly described in my earlier message is
much more like a proxy.

> >Personally, I have been using a class template 'locked', which is basically
> >handle to a lockable or guarded object/resource.
> The problem is that "locked" is a description of state, ie a query or
> state flag name rather than an object that performs an action.

Yes. By instantiating locked (guarded_map_handle), you change the state of the
lock (guarded_map), and refer to the resource (guarded_map) guarded by the
lock through locked (guarded_map_handle).

    { guarded_map_type::handle guarded_map_handle(guarded_map);

      // The operator-> returns a pointer to the interface.

Boost list run by bdawes at, gregod at, cpdaniel at, john at