5.6.9.1.1 The Locking Service C Interface

This section describes how to use the locking service C language interface. To use the function interface instead, see Section 5.6.9.1.2, “The Locking Service Function Interface” For general characteristics of the locking service interface, see Section 5.6.9.1, “The Locking Service”. For general information about plugin services, see Section 5.6.9, “MySQL Plugin Services”.

Source files that use the locking service should include this header file:

#include <mysql/service_locking.h>

To acquire one or more locks, call this function:

int mysql_acquire_locking_service_locks(MYSQL_THD opaque_thd,
                                        const char* lock_namespace,
                                        const char**lock_names,
                                        size_t lock_num,
                                        enum enum_locking_service_lock_type lock_type,
                                        unsigned long lock_timeout);

The arguments have these meanings:

To release locks acquired for a given namespace, call this function:

int mysql_release_locking_service_locks(MYSQL_THD opaque_thd,
                                        const char* lock_namespace);

The arguments have these meanings:

Locks acquired or waited for by the locking service can be monitored at the SQL level using the Performance Schema. For details, see Locking Service Monitoring.