My Project
Classes | Public Member Functions
Owned_gtids Class Reference

#include <rpl_gtid.h>

List of all members.

Classes

class  Gtid_iterator
struct  Node
 Represents one owned group.

Public Member Functions

 Owned_gtids (Checkable_rwlock *sid_lock)
 ~Owned_gtids ()
 Destroys this Owned_gtids.
enum_return_status add_gtid_owner (const Gtid &gtid, my_thread_id owner)
my_thread_id get_owner (const Gtid &gtid) const
void remove_gtid (const Gtid &gtid)
enum_return_status ensure_sidno (rpl_sidno sidno)
bool is_intersection_nonempty (const Gtid_set *other) const
bool is_empty () const
 Returns true if this Owned_gtids is empty.
rpl_sidno get_max_sidno () const
 Returns the maximal sidno that this Owned_gtids currently has space for.
int to_string (char *out) const
size_t get_max_string_length () const
bool thread_owns_anything (my_thread_id thd_id) const
char * to_string () const
void print () const
 Debug only: print this Owned_gtids to stdout.
void dbug_print (const char *text="") const

Detailed Description

Represents the set of GTIDs that are owned by some thread.

This data structure has a read-write lock that protects the number of SIDNOs. The lock is provided by the invoker of the constructor and it is generally the caller's responsibility to acquire the read lock. Access methods assert that the caller already holds the read (or write) lock. If a method of this class grows the number of SIDNOs, then the method temporarily upgrades this lock to a write lock and then degrades it to a read lock again; there will be a short period when the lock is not held at all.

The internal representation is a DYNAMIC_ARRAY that maps SIDNO to HASH, where each HASH maps GNO to my_thread_id.


Constructor & Destructor Documentation

Constructs a new, empty Owned_gtids object.

Parameters:
sid_lockRead-write lock that protects updates to the number of SIDs.

Member Function Documentation

enum_return_status Owned_gtids::add_gtid_owner ( const Gtid gtid,
my_thread_id  owner 
)

Add a GTID to this Owned_gtids.

Parameters:
gtidThe Gtid to add.
ownerThe my_thread_id of the group to add.
Returns:
RETURN_STATUS_OK or RETURN_STATUS_REPORTED_ERROR.
void Owned_gtids::dbug_print ( const char *  text = "") const [inline]

Print this Owned_gtids to the trace file if debug is enabled; no-op otherwise.

enum_return_status Owned_gtids::ensure_sidno ( rpl_sidno  sidno)

Ensures that this Owned_gtids object can accomodate SIDNOs up to the given SIDNO.

If this Owned_gtids object needs to be resized, then the lock will be temporarily upgraded to a write lock and then degraded to a read lock again; there will be a short period when the lock is not held at all.

Parameters:
sidnoThe SIDNO.
Returns:
RETURN_STATUS_OK or RETURN_STATUS_REPORTED_ERROR.
size_t Owned_gtids::get_max_string_length ( ) const [inline]

Return an upper bound on the length of the string representation of this Owned_groups. The actual length may be smaller. This includes the trailing '\0'.

my_thread_id Owned_gtids::get_owner ( const Gtid gtid) const

Returns the owner of the given GTID, or 0 if the GTID is not owned.

Parameters:
GtidThe Gtid to query.
Returns:
my_thread_id of the thread that owns the group, or 0 if the group is not owned.
bool Owned_gtids::is_intersection_nonempty ( const Gtid_set other) const

Returns true if there is a least one element of this Owned_gtids set in the other Gtid_set.

void Owned_gtids::remove_gtid ( const Gtid gtid)

Removes the given GTID.

If the group does not exist in this Owned_gtids object, does nothing.

Parameters:
gtidThe Gtid.
bool Owned_gtids::thread_owns_anything ( my_thread_id  thd_id) const [inline]

Return true if the given thread is the owner of any groups.

int Owned_gtids::to_string ( char *  out) const [inline]

Write a string representation of this Owned_groups to the given buffer.

Parameters:
outBuffer to write to.
Returns:
Number of characters written.
char* Owned_gtids::to_string ( ) const [inline]

Debug only: return a newly allocated string representation of this Owned_gtids.


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines