ucommon  7.0.0
About: GNU uCommon C++ is a portable and optimized class framework for writing C++ applications that need to use threads and support concurrent synchronization, and that use sockets, XML parsing, object serialization, thread-optimized string and data structure classes, etc..
  Fossies Dox: ucommon-7.0.0.tar.gz  ("unofficial" and yet experimental doxygen-generated source code documentation)  

Loading...
Searching...
No Matches
ucommon::shared_access Class Reference

A kind of smart pointer object to support shared locking protocol. More...

#include <access.h>

Collaboration diagram for ucommon::shared_access:
[legend]

Public Member Functions

 shared_access (SharedProtocol *object)
 Create an instance of an exclusive object reference. More...
 
 shared_access (const shared_access &copy)
 
shared_accessoperator= (const shared_access &copy)
 
 ~shared_access ()
 Destroy reference to shared locked object, release lock. More...
 
bool operator! () const
 Test if the reference holds an active lock. More...
 
 operator bool () const
 Test if the reference holds an active lock. More...
 
void release (void)
 Release a held lock programmatically. More...
 
void exclusive (void)
 Call exclusive access on referenced objects protocol. More...
 
void share (void)
 Restore shared access on referenced objects protocol. More...
 

Private Attributes

SharedProtocollock
 
int state
 
bool modify
 

Detailed Description

A kind of smart pointer object to support shared locking protocol.

This object initiates a shared lock for the object being referenced when it is instantiated, and releases the shared lock when it is destroyed. You would pass the pointer an object that has the Shared as a base class.

Author
David Sugar dyfet.nosp@m.@gnu.nosp@m.telep.nosp@m.hony.nosp@m..org

Definition at line 224 of file access.h.

Constructor & Destructor Documentation

◆ shared_access() [1/2]

ucommon::shared_access::shared_access ( SharedProtocol object)

Create an instance of an exclusive object reference.

Parameters
objectcontaining Exclusive base class protocol to lock.

◆ shared_access() [2/2]

ucommon::shared_access::shared_access ( const shared_access copy)

◆ ~shared_access()

ucommon::shared_access::~shared_access ( )

Destroy reference to shared locked object, release lock.

Member Function Documentation

◆ exclusive()

void ucommon::shared_access::exclusive ( void  )

Call exclusive access on referenced objects protocol.

◆ operator bool()

ucommon::shared_access::operator bool ( ) const
inline

Test if the reference holds an active lock.

Returns
true if locking an object.

Definition at line 259 of file access.h.

◆ operator!()

bool ucommon::shared_access::operator! ( ) const
inline

Test if the reference holds an active lock.

Returns
true if is not locking an object.

Definition at line 251 of file access.h.

◆ operator=()

shared_access & ucommon::shared_access::operator= ( const shared_access copy)

◆ release()

void ucommon::shared_access::release ( void  )

Release a held lock programmatically.

This can be used to de-reference the object being share locked without having to wait for the destructor to be called when the shared_lock falls out of scope.

◆ share()

void ucommon::shared_access::share ( void  )

Restore shared access on referenced objects protocol.

Member Data Documentation

◆ lock

SharedProtocol* ucommon::shared_access::lock
private

Definition at line 227 of file access.h.

◆ modify

bool ucommon::shared_access::modify
private

Definition at line 229 of file access.h.

◆ state

int ucommon::shared_access::state
private

Definition at line 228 of file access.h.


The documentation for this class was generated from the following file: