CIDLib Core Class Reference: MLockable

Class: MLockable


Facility: CIDLib.Dll
Header: CIDLib_Lock.Hpp
Derived From: N/A

MLockable is a mixin class, which refers to the style of mixin multiple inheritance used by CIDLib. It is mixed into other classes in order to graft a particular API upon them, which allows them to be used by code which understands the mixed in (usually virtual) API but has no clue about the object its grafted onto.

This particular mixin applies a (guess it!) locking API onto another class. Classes like TMutexSem mix in this class so that they can be dealt with via this very abstract API in a generic way. Windows also mix it in so that windows can be locked. The big advantage of this is that all of these objects can then be locked via the TLocker class. See the locker class for an example of this kind of usage.

Constructors

There are no public constructors for this class. It is pure virtual and has no members to initialize. The mixed in class just needs to override the pure virtual methods and perform the correct action.

Caveats/Gotchas

Keep these issues in mind when mixin in MLockable:
  1. Obviously multiple inheritance has its gotchas, particular until I get real RTTI support in the compiler. You should understand the ramifications of MI before making extensive use of it. It can bite you in ever so clever ways.
  2. When creating an abstract base class whose derivatives all must be lockable (and provide the functionality themselves), just mix it in but don't provide the implementations of its virtual methods. This just passes on the burden of implementation to derived classes.

Public Methods

This guy don't have a lot of methods because its a very simple API. It just provides a couple of public, pure virtual methods that must be implemented by the derived classes.
  • Lock()
  • Unlock()

  • CIDCorp
    Dean Roddey
    Internet: droddey@ng.netgate.net
    CIS: 72170,1614