Retro video games delivered to your door every month!
Click above to get retro games delivered to your door ever month!
X-Hacker.org- Comix 3.0 Reference Manual - <b>cmxshared()</b> get/set shared/locking mode for database & indexes http://www.X-Hacker.org [<<Previous Entry] [^^Up^^] [Next Entry>>] [Menu] [About The Guide]
cmxShared()           Get/set shared/locking mode for database & indexes
------------------------------------------------------------------------------

Synopsis

    cmxShared([lShared]) -> lWasShared

Arguments

    lShared is an optional parameter which specifies whether to set shared
    mode on (.T.) or off (.F.).  If lShared is omitted, no change is made in
    the sharing mode.

Returns

    cmxShared() returns the previous SHARED mode of the database.
    cmxShared() returns .T. if the database is in SHARED mode (i.e.,
    multi-user overhead/locking) and .F. if the database is in EXCLUSIVE
    mode.

Description

    cmxShared() is used both to get and control the current sharing mode of
    the database and associated indexes.

    This function has 2 major uses:

    1) Determine if a database was opened SHARED or EXCLUSIVE.
    2) Dynamically change the sharing mode of a database and associated
       orders.

    When a database is USE'd in SHARED mode, there is additional overhead in
    accessing both the database and indexes.  Specifically, locking is
    required _and_ no buffering can be performed (this is true with DBFNTX,
    Comix and all other RDD's).

    In some instances, however, you may want the database to be used by
    multiple users, but do not want multi-user overhead/locking.

    An excellent example of this is a read-only database which is being used
    by multiple users.  In this case, you can open the database in SHARED
    mode, and then call cmxShared(.f.) to override the default locking
    behavior.

    This tells Comix to treat the database as if it is were exclusive mode
    (thus eliminating all the multi-user overhead for accessing the
    database).

    NOTE: You should _not_ use this function to switch from shared mode
          if applications will be updating the database.

Example

    USE demo SHARED READONLY        && Open in SHARED mode originally so that
                                    && other apps can open the database too

    ? cmxShared()                   && Returns .T. (in shared mode)

        //  We know no one will be updating the database, so no sense taking
        //  the hit on multi-user overhead
    cmxShared(.F.)                  && Switch to non-locking mode

        //  Now there will be no m/u overhead for reads

    ? cmxShared()                   && Returns .F. (no multi-user overhead)

See Also

    None.


Online resources provided by: http://www.X-Hacker.org --- NG 2 HTML conversion by Dave Pearson