~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to storage/innobase/include/sync0arr.h

  • Committer: Monty Taylor
  • Date: 2010-12-24 02:13:05 UTC
  • mto: This revision was merged to the branch mainline in revision 2038.
  • Revision ID: mordred@inaugust.com-20101224021305-e3slv1cyjczqorij
Changed the bzrignore file.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/******************************************************
2
 
The wait array used in synchronization primitives
3
 
 
4
 
(c) 1995 Innobase Oy
5
 
 
6
 
Created 9/5/1995 Heikki Tuuri
7
 
*******************************************************/
8
 
 
9
 
#ifndef sync0arr_h
10
 
#define sync0arr_h
11
 
 
12
 
#include "univ.i"
13
 
#include "ut0lst.h"
14
 
#include "ut0mem.h"
15
 
#include "os0thread.h"
16
 
 
17
 
typedef struct sync_cell_struct         sync_cell_t;
18
 
typedef struct sync_array_struct        sync_array_t;
19
 
 
20
 
#define SYNC_ARRAY_OS_MUTEX     1
21
 
#define SYNC_ARRAY_MUTEX        2
22
 
 
23
 
/***********************************************************************
24
 
Creates a synchronization wait array. It is protected by a mutex
25
 
which is automatically reserved when the functions operating on it
26
 
are called. */
27
 
UNIV_INTERN
28
 
sync_array_t*
29
 
sync_array_create(
30
 
/*==============*/
31
 
                                /* out, own: created wait array */
32
 
        ulint   n_cells,        /* in: number of cells in the array
33
 
                                to create */
34
 
        ulint   protection);    /* in: either SYNC_ARRAY_OS_MUTEX or
35
 
                                SYNC_ARRAY_MUTEX: determines the type
36
 
                                of mutex protecting the data structure */
37
 
/**********************************************************************
38
 
Frees the resources in a wait array. */
39
 
UNIV_INTERN
40
 
void
41
 
sync_array_free(
42
 
/*============*/
43
 
        sync_array_t*   arr);   /* in, own: sync wait array */
44
 
/**********************************************************************
45
 
Reserves a wait array cell for waiting for an object.
46
 
The event of the cell is reset to nonsignalled state. */
47
 
UNIV_INTERN
48
 
void
49
 
sync_array_reserve_cell(
50
 
/*====================*/
51
 
        sync_array_t*   arr,    /* in: wait array */
52
 
        void*           object, /* in: pointer to the object to wait for */
53
 
        ulint           type,   /* in: lock request type */
54
 
        const char*     file,   /* in: file where requested */
55
 
        ulint           line,   /* in: line where requested */
56
 
        ulint*          index); /* out: index of the reserved cell */
57
 
/**********************************************************************
58
 
This function should be called when a thread starts to wait on
59
 
a wait array cell. In the debug version this function checks
60
 
if the wait for a semaphore will result in a deadlock, in which
61
 
case prints info and asserts. */
62
 
UNIV_INTERN
63
 
void
64
 
sync_array_wait_event(
65
 
/*==================*/
66
 
        sync_array_t*   arr,    /* in: wait array */
67
 
        ulint           index);  /* in: index of the reserved cell */
68
 
/**********************************************************************
69
 
Frees the cell. NOTE! sync_array_wait_event frees the cell
70
 
automatically! */
71
 
UNIV_INTERN
72
 
void
73
 
sync_array_free_cell(
74
 
/*=================*/
75
 
        sync_array_t*   arr,    /* in: wait array */
76
 
        ulint           index); /* in: index of the cell in array */
77
 
/**************************************************************************
78
 
Note that one of the wait objects was signalled. */
79
 
UNIV_INTERN
80
 
void
81
 
sync_array_object_signalled(
82
 
/*========================*/
83
 
        sync_array_t*   arr);   /* in: wait array */
84
 
/**************************************************************************
85
 
If the wakeup algorithm does not work perfectly at semaphore relases,
86
 
this function will do the waking (see the comment in mutex_exit). This
87
 
function should be called about every 1 second in the server. */
88
 
UNIV_INTERN
89
 
void
90
 
sync_arr_wake_threads_if_sema_free(void);
91
 
/*====================================*/
92
 
/**************************************************************************
93
 
Prints warnings of long semaphore waits to stderr. */
94
 
UNIV_INTERN
95
 
ibool
96
 
sync_array_print_long_waits(void);
97
 
/*=============================*/
98
 
                        /* out: TRUE if fatal semaphore wait threshold
99
 
                        was exceeded */
100
 
/************************************************************************
101
 
Validates the integrity of the wait array. Checks
102
 
that the number of reserved cells equals the count variable. */
103
 
UNIV_INTERN
104
 
void
105
 
sync_array_validate(
106
 
/*================*/
107
 
        sync_array_t*   arr);   /* in: sync wait array */
108
 
/**************************************************************************
109
 
Prints info of the wait array. */
110
 
UNIV_INTERN
111
 
void
112
 
sync_array_print_info(
113
 
/*==================*/
114
 
        FILE*           file,   /* in: file where to print */
115
 
        sync_array_t*   arr);   /* in: wait array */
116
 
 
117
 
 
118
 
#ifndef UNIV_NONINL
119
 
#include "sync0arr.ic"
120
 
#endif
121
 
 
122
 
#endif