~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2008-09-14 22:10:23 UTC
  • mto: This revision was merged to the branch mainline in revision 388.
  • Revision ID: monty@inaugust.com-20080914221023-otz8vuui590zp5yf
Got rid of libsqlcommon and some surious defines.

Show diffs side-by-side

added added

removed removed

Lines of Context:
40
40
                                        in the signaled state, i.e., a thread
41
41
                                        does not stop if it tries to wait for
42
42
                                        this event */
43
 
        ib_int64_t      signal_count;   /* this is incremented each time
 
43
        ib_longlong     signal_count;   /* this is incremented each time
44
44
                                        the event becomes signaled */
45
45
        pthread_cond_t  cond_var;       /* condition variable is used in
46
46
                                        waiting for the event */
69
69
 
70
70
/*************************************************************
71
71
Initializes global event and OS 'slow' mutex lists. */
72
 
UNIV_INTERN
 
72
 
73
73
void
74
74
os_sync_init(void);
75
75
/*==============*/
76
76
/*************************************************************
77
77
Frees created events and OS 'slow' mutexes. */
78
 
UNIV_INTERN
 
78
 
79
79
void
80
80
os_sync_free(void);
81
81
/*==============*/
83
83
Creates an event semaphore, i.e., a semaphore which may just have two states:
84
84
signaled and nonsignaled. The created event is manual reset: it must be reset
85
85
explicitly by calling sync_os_reset_event. */
86
 
UNIV_INTERN
 
86
 
87
87
os_event_t
88
88
os_event_create(
89
89
/*============*/
94
94
/*************************************************************
95
95
Creates an auto-reset event semaphore, i.e., an event which is automatically
96
96
reset when a single thread is released. Works only in Windows. */
97
 
UNIV_INTERN
 
97
 
98
98
os_event_t
99
99
os_event_create_auto(
100
100
/*=================*/
105
105
/**************************************************************
106
106
Sets an event semaphore to the signaled state: lets waiting threads
107
107
proceed. */
108
 
UNIV_INTERN
 
108
 
109
109
void
110
110
os_event_set(
111
111
/*=========*/
112
112
        os_event_t      event); /* in: event to set */
113
113
/**************************************************************
114
114
Resets an event semaphore to the nonsignaled state. Waiting threads will
115
 
stop to wait for the event.
116
 
The return value should be passed to os_even_wait_low() if it is desired
117
 
that this thread should not wait in case of an intervening call to
118
 
os_event_set() between this os_event_reset() and the
119
 
os_event_wait_low() call. See comments for os_event_wait_low(). */
120
 
UNIV_INTERN
121
 
ib_int64_t
 
115
stop to wait for the event. */
 
116
 
 
117
void
122
118
os_event_reset(
123
119
/*===========*/
124
120
        os_event_t      event); /* in: event to reset */
125
121
/**************************************************************
126
122
Frees an event object. */
127
 
UNIV_INTERN
 
123
 
128
124
void
129
125
os_event_free(
130
126
/*==========*/
131
127
        os_event_t      event); /* in: event to free */
132
 
 
133
128
/**************************************************************
134
129
Waits for an event object until it is in the signaled state. If
135
130
srv_shutdown_state == SRV_SHUTDOWN_EXIT_THREADS this also exits the
136
131
waiting thread when the event becomes signaled (or immediately if the
137
 
event is already in the signaled state).
138
 
 
139
 
Typically, if the event has been signalled after the os_event_reset()
140
 
we'll return immediately because event->is_set == TRUE.
141
 
There are, however, situations (e.g.: sync_array code) where we may
142
 
lose this information. For example:
143
 
 
144
 
thread A calls os_event_reset()
145
 
thread B calls os_event_set()   [event->is_set == TRUE]
146
 
thread C calls os_event_reset() [event->is_set == FALSE]
147
 
thread A calls os_event_wait()  [infinite wait!]
148
 
thread C calls os_event_wait()  [infinite wait!]
149
 
 
150
 
Where such a scenario is possible, to avoid infinite wait, the
151
 
value returned by os_event_reset() should be passed in as
152
 
reset_sig_count. */
153
 
UNIV_INTERN
 
132
event is already in the signaled state). */
 
133
 
154
134
void
155
 
os_event_wait_low(
156
 
/*==============*/
157
 
        os_event_t      event,          /* in: event to wait */
158
 
        ib_int64_t      reset_sig_count);/* in: zero or the value
159
 
                                        returned by previous call of
160
 
                                        os_event_reset(). */
161
 
 
162
 
#define os_event_wait(event) os_event_wait_low(event, 0)
163
 
 
 
135
os_event_wait(
 
136
/*==========*/
 
137
        os_event_t      event); /* in: event to wait */
164
138
/**************************************************************
165
139
Waits for an event object until it is in the signaled state or
166
140
a timeout is exceeded. In Unix the timeout is always infinite. */
167
 
UNIV_INTERN
 
141
 
168
142
ulint
169
143
os_event_wait_time(
170
144
/*===============*/
178
152
/**************************************************************
179
153
Waits for any event in an OS native event array. Returns if even a single
180
154
one is signaled or becomes signaled. */
181
 
UNIV_INTERN
 
155
 
182
156
ulint
183
157
os_event_wait_multiple(
184
158
/*===================*/
193
167
/*************************************************************
194
168
Creates an operating system mutex semaphore. Because these are slow, the
195
169
mutex semaphore of InnoDB itself (mutex_t) should be used where possible. */
196
 
UNIV_INTERN
 
170
 
197
171
os_mutex_t
198
172
os_mutex_create(
199
173
/*============*/
202
176
                                the mutex is created without a name */
203
177
/**************************************************************
204
178
Acquires ownership of a mutex semaphore. */
205
 
UNIV_INTERN
 
179
 
206
180
void
207
181
os_mutex_enter(
208
182
/*===========*/
209
183
        os_mutex_t      mutex); /* in: mutex to acquire */
210
184
/**************************************************************
211
185
Releases ownership of a mutex. */
212
 
UNIV_INTERN
 
186
 
213
187
void
214
188
os_mutex_exit(
215
189
/*==========*/
216
190
        os_mutex_t      mutex); /* in: mutex to release */
217
191
/**************************************************************
218
192
Frees an mutex object. */
219
 
UNIV_INTERN
 
193
 
220
194
void
221
195
os_mutex_free(
222
196
/*==========*/
234
208
        os_fast_mutex_t*        fast_mutex);    /* in: mutex to acquire */
235
209
/**************************************************************
236
210
Releases ownership of a fast mutex. */
237
 
UNIV_INTERN
 
211
 
238
212
void
239
213
os_fast_mutex_unlock(
240
214
/*=================*/
241
215
        os_fast_mutex_t*        fast_mutex);    /* in: mutex to release */
242
216
/*************************************************************
243
217
Initializes an operating system fast mutex semaphore. */
244
 
UNIV_INTERN
 
218
 
245
219
void
246
220
os_fast_mutex_init(
247
221
/*===============*/
248
222
        os_fast_mutex_t*        fast_mutex);    /* in: fast mutex */
249
223
/**************************************************************
250
224
Acquires ownership of a fast mutex. */
251
 
UNIV_INTERN
 
225
 
252
226
void
253
227
os_fast_mutex_lock(
254
228
/*===============*/
255
229
        os_fast_mutex_t*        fast_mutex);    /* in: mutex to acquire */
256
230
/**************************************************************
257
231
Frees an mutex object. */
258
 
UNIV_INTERN
 
232
 
259
233
void
260
234
os_fast_mutex_free(
261
235
/*===============*/