ScaleOut C++ Native Client API  5.1
 All Classes Functions Variables Typedefs Enumerations Enumerator Friends Pages
sosscli::LockTicket Class Reference

The LockTicket class serves as a RAII-style wrapper around the internal lock ticket identifier returned by ScaleOut's low-level APIs. More...

#include <lock_ticket.h>

Public Member Functions

 LockTicket (void)
 Default constructor. Constructs an empty and uninitialized lock ticket that is not ready for use until assigned.
 
 LockTicket (SOSS_OBJKEY const &key, const int32_t ticket)
 Constructs a LockTicket for a given object. More...
 
 LockTicket (const LockTicket &other)
 Copy constructor. More...
 
void release (void)
 Marks that the lock ticket has been unlocked by the server.
 
bool locked (void) const
 Gets the current state of the lock ticket. More...
 
bool is_null_ticket (void) const
 Determines whether the lock ticket is valid. More...
 
LockTicketoperator= (const LockTicket &rhs)
 Assignment operator.
 
 operator int32_t () const
 Conversion operator to treat LockTicket implicitly as a native lock ticket. More...
 

Detailed Description

The LockTicket class serves as a RAII-style wrapper around the internal lock ticket identifier returned by ScaleOut's low-level APIs.

Its implementation counts references to a given lock ticket and automatically unlocks the associated object if its last reference falls out of scope without the lock having been explicitly released by the client app.

Constructor & Destructor Documentation

sosscli::LockTicket::LockTicket ( SOSS_OBJKEY const &  key,
const int32_t  ticket 
)

Constructs a LockTicket for a given object.

Parameters
keySOSS object key associated with the lock ticket.
ticketSOSS lock ticket identifier as returned by the server.
sosscli::LockTicket::LockTicket ( const LockTicket other)

Copy constructor.

Parameters
otherThe LockTicket that this instance is being copied from.

Member Function Documentation

bool sosscli::LockTicket::is_null_ticket ( void  ) const

Determines whether the lock ticket is valid.

Returns
Boolean indicating whether the lock ticket is valid.
bool sosscli::LockTicket::locked ( void  ) const

Gets the current state of the lock ticket.

Returns
Boolean indicating whether the lock ticket is locked by the server.
sosscli::LockTicket::operator int32_t ( ) const
inline

Conversion operator to treat LockTicket implicitly as a native lock ticket.

Note: Locally storing a LockTicket as an integer will result in an unmanaged copy of the lock ticket, which may result in the locally stored lock ticket becoming unexpectedly invalid if all managed references fall out of scope, or release() is called!

Returns
Integer representing the lock ticket used in low-level server calls.

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