summaryrefslogtreecommitdiff
path: root/storage/example
diff options
context:
space:
mode:
authorMarc Alff <marc.alff@sun.com>2009-12-04 18:26:15 -0700
committerMarc Alff <marc.alff@sun.com>2009-12-04 18:26:15 -0700
commit04fe40393d9d0ef81cc6a770bda67ab67fe4154e (patch)
tree9ca152d7f2ac50cfd8b7fca83f87cb06148d97a0 /storage/example
parent560e76c567c3551f5a4320acfc954200e8330ad8 (diff)
downloadmariadb-git-04fe40393d9d0ef81cc6a770bda67ab67fe4154e.tar.gz
WL#2360 Performance schema
Part II, engines instrumentation
Diffstat (limited to 'storage/example')
-rw-r--r--storage/example/ha_example.cc49
-rw-r--r--storage/example/ha_example.h4
2 files changed, 40 insertions, 13 deletions
diff --git a/storage/example/ha_example.cc b/storage/example/ha_example.cc
index 743c7423b80..8d2eb914a97 100644
--- a/storage/example/ha_example.cc
+++ b/storage/example/ha_example.cc
@@ -112,7 +112,7 @@ handlerton *example_hton;
static HASH example_open_tables;
/* The mutex used to init the hash; variable for example share methods */
-pthread_mutex_t example_mutex;
+mysql_mutex_t example_mutex;
/**
@brief
@@ -126,13 +126,39 @@ static uchar* example_get_key(EXAMPLE_SHARE *share, size_t *length,
return (uchar*) share->table_name;
}
+#ifdef HAVE_PSI_INTERFACE
+static PSI_mutex_key ex_key_mutex_example, ex_key_mutex_EXAMPLE_SHARE_mutex;
+
+static PSI_mutex_info all_example_mutexes[]=
+{
+ { &ex_key_mutex_example, "example", PSI_FLAG_GLOBAL},
+ { &ex_key_mutex_EXAMPLE_SHARE_mutex, "EXAMPLE_SHARE::mutex", 0}
+};
+
+static void init_example_psi_keys()
+{
+ const char* category= "example";
+ int count;
+
+ if (PSI_server == NULL)
+ return;
+
+ count= array_elements(all_example_mutexes);
+ PSI_server->register_mutex(category, all_example_mutexes, count);
+}
+#endif
+
static int example_init_func(void *p)
{
DBUG_ENTER("example_init_func");
+#ifdef HAVE_PSI_INTERFACE
+ init_example_psi_keys();
+#endif
+
example_hton= (handlerton *)p;
- pthread_mutex_init(&example_mutex,MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(ex_key_mutex_example, &example_mutex, MY_MUTEX_INIT_FAST);
(void) my_hash_init(&example_open_tables,system_charset_info,32,0,0,
(my_hash_get_key) example_get_key,0,0);
@@ -152,7 +178,7 @@ static int example_done_func(void *p)
if (example_open_tables.records)
error= 1;
my_hash_free(&example_open_tables);
- pthread_mutex_destroy(&example_mutex);
+ mysql_mutex_destroy(&example_mutex);
DBUG_RETURN(0);
}
@@ -172,7 +198,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
uint length;
char *tmp_name;
- pthread_mutex_lock(&example_mutex);
+ mysql_mutex_lock(&example_mutex);
length=(uint) strlen(table_name);
if (!(share=(EXAMPLE_SHARE*) my_hash_search(&example_open_tables,
@@ -185,7 +211,7 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
&tmp_name, length+1,
NullS)))
{
- pthread_mutex_unlock(&example_mutex);
+ mysql_mutex_unlock(&example_mutex);
return NULL;
}
@@ -196,15 +222,16 @@ static EXAMPLE_SHARE *get_share(const char *table_name, TABLE *table)
if (my_hash_insert(&example_open_tables, (uchar*) share))
goto error;
thr_lock_init(&share->lock);
- pthread_mutex_init(&share->mutex,MY_MUTEX_INIT_FAST);
+ mysql_mutex_init(ex_key_mutex_EXAMPLE_SHARE_mutex,
+ &share->mutex, MY_MUTEX_INIT_FAST);
}
share->use_count++;
- pthread_mutex_unlock(&example_mutex);
+ mysql_mutex_unlock(&example_mutex);
return share;
error:
- pthread_mutex_destroy(&share->mutex);
+ mysql_mutex_destroy(&share->mutex);
my_free(share, MYF(0));
return NULL;
@@ -219,15 +246,15 @@ error:
static int free_share(EXAMPLE_SHARE *share)
{
- pthread_mutex_lock(&example_mutex);
+ mysql_mutex_lock(&example_mutex);
if (!--share->use_count)
{
my_hash_delete(&example_open_tables, (uchar*) share);
thr_lock_delete(&share->lock);
- pthread_mutex_destroy(&share->mutex);
+ mysql_mutex_destroy(&share->mutex);
my_free(share, MYF(0));
}
- pthread_mutex_unlock(&example_mutex);
+ mysql_mutex_unlock(&example_mutex);
return 0;
}
diff --git a/storage/example/ha_example.h b/storage/example/ha_example.h
index ec3987ced5d..4f88d6ced8e 100644
--- a/storage/example/ha_example.h
+++ b/storage/example/ha_example.h
@@ -1,4 +1,4 @@
-/* Copyright (C) 2003 MySQL AB
+/* Copyright (C) 2003 MySQL AB, 2008-2009 Sun Microsystems, Inc
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -42,7 +42,7 @@
typedef struct st_example_share {
char *table_name;
uint table_name_length,use_count;
- pthread_mutex_t mutex;
+ mysql_mutex_t mutex;
THR_LOCK lock;
} EXAMPLE_SHARE;