~drizzle-trunk/drizzle/development

« back to all changes in this revision

Viewing changes to plugin/innobase/include/sync0sync.ic

  • Committer: Lee Bieber
  • Date: 2010-11-07 19:34:48 UTC
  • mfrom: (1910.1.2 build)
  • Revision ID: kalebral@gmail.com-20101107193448-64kdu912qej354sh
Merge Stewart - including adapting and expanding the "differences from mysql" page from the wiki.
Merge Stewart - fix bug 668143: drizzleslap with --commit runs second iteration data load in a transaction

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*****************************************************************************
2
2
 
3
 
Copyright (C) 1995, 2009, Innobase Oy. All Rights Reserved.
4
 
Copyright (C) 2008, Google Inc.
 
3
Copyright (c) 1995, 2009, Innobase Oy. All Rights Reserved.
 
4
Copyright (c) 2008, Google Inc.
5
5
 
6
6
Portions of this file contain modifications contributed and copyrighted by
7
7
Google, Inc. Those modifications are gratefully acknowledged and are described
152
152
}
153
153
 
154
154
/******************************************************************//**
155
 
NOTE! Use the corresponding macro mutex_exit(), not directly this function!
156
155
Unlocks a mutex owned by the current thread. */
157
156
UNIV_INLINE
158
157
void
159
 
mutex_exit_func(
160
 
/*============*/
 
158
mutex_exit(
 
159
/*=======*/
161
160
        mutex_t*        mutex)  /*!< in: pointer to mutex */
162
161
{
163
162
        ut_ad(mutex_own(mutex));
221
220
 
222
221
        mutex_spin_wait(mutex, file_name, line);
223
222
}
224
 
 
225
 
#ifdef UNIV_PFS_MUTEX
226
 
/******************************************************************//**
227
 
NOTE! Please use the corresponding macro mutex_enter(), not directly
228
 
this function!
229
 
This is a performance schema instrumented wrapper function for
230
 
mutex_enter_func(). */
231
 
UNIV_INLINE
232
 
void
233
 
pfs_mutex_enter_func(
234
 
/*=================*/
235
 
        mutex_t*        mutex,  /*!< in: pointer to mutex */
236
 
        const char*     file_name,      /*!< in: file name where locked */
237
 
        ulint           line)           /*!< in: line where locked */
238
 
{
239
 
        struct PSI_mutex_locker*        locker = NULL;
240
 
        PSI_mutex_locker_state          state;
241
 
        int     result = 0;
242
 
 
243
 
        if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) {
244
 
                locker = PSI_server->get_thread_mutex_locker(
245
 
                                &state, mutex->pfs_psi, PSI_MUTEX_LOCK);
246
 
                if (locker) {
247
 
                        PSI_server->start_mutex_wait(locker, file_name, line);
248
 
                }
249
 
        }
250
 
 
251
 
        mutex_enter_func(mutex, file_name, line);
252
 
 
253
 
        if (locker) {
254
 
                PSI_server->end_mutex_wait(locker, result);
255
 
        }
256
 
}
257
 
/********************************************************************//**
258
 
NOTE! Please use the corresponding macro mutex_enter_nowait(), not directly
259
 
this function!
260
 
This is a performance schema instrumented wrapper function for
261
 
mutex_enter_nowait_func.
262
 
@return 0 if succeed, 1 if not */
263
 
UNIV_INLINE
264
 
ulint
265
 
pfs_mutex_enter_nowait_func(
266
 
/*========================*/
267
 
        mutex_t*        mutex,          /*!< in: pointer to mutex */
268
 
        const char*     file_name,      /*!< in: file name where mutex
269
 
                                        requested */
270
 
        ulint           line)           /*!< in: line where requested */
271
 
{
272
 
        ulint   ret;
273
 
        struct PSI_mutex_locker*        locker = NULL;
274
 
        PSI_mutex_locker_state          state;
275
 
        int     result = 0;
276
 
 
277
 
        if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) {
278
 
                locker = PSI_server->get_thread_mutex_locker(
279
 
                                &state, mutex->pfs_psi, PSI_MUTEX_LOCK);
280
 
                if (locker) {
281
 
                        PSI_server->start_mutex_wait(locker, file_name, line);
282
 
                }
283
 
        }
284
 
 
285
 
        ret = mutex_enter_nowait_func(mutex, file_name, line);
286
 
 
287
 
        if (locker) {
288
 
                PSI_server->end_mutex_wait(locker, result);
289
 
        }
290
 
 
291
 
        return(ret);
292
 
}
293
 
/******************************************************************//**
294
 
NOTE! Please use the corresponding macro mutex_exit(), not directly
295
 
this function!
296
 
A wrap function of mutex_exit_func() with performance schema instrumentation.
297
 
Unlocks a mutex owned by the current thread. */
298
 
UNIV_INLINE
299
 
void
300
 
pfs_mutex_exit_func(
301
 
/*================*/
302
 
        mutex_t*        mutex)  /*!< in: pointer to mutex */
303
 
{
304
 
        if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) {
305
 
                PSI_server->unlock_mutex(mutex->pfs_psi);
306
 
        }
307
 
 
308
 
        mutex_exit_func(mutex);
309
 
}
310
 
 
311
 
/******************************************************************//**
312
 
NOTE! Please use the corresponding macro mutex_create(), not directly
313
 
this function!
314
 
A wrapper function for mutex_create_func(), registers the mutex
315
 
with performance schema if "UNIV_PFS_MUTEX" is defined when
316
 
creating the mutex */
317
 
UNIV_INLINE
318
 
void
319
 
pfs_mutex_create_func(
320
 
/*==================*/
321
 
        mysql_pfs_key_t key,            /*!< in: Performance Schema key */
322
 
        mutex_t*        mutex,          /*!< in: pointer to memory */
323
 
# ifdef UNIV_DEBUG
324
 
        const char*     cmutex_name,    /*!< in: mutex name */
325
 
#  ifdef UNIV_SYNC_DEBUG
326
 
        ulint           level,          /*!< in: level */
327
 
#  endif /* UNIV_SYNC_DEBUG */
328
 
# endif /* UNIV_DEBUG */
329
 
        const char*     cfile_name,     /*!< in: file name where created */
330
 
        ulint           cline)          /*!< in: file line where created */
331
 
{
332
 
        mutex->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key))
333
 
                                ? PSI_server->init_mutex(key, mutex)
334
 
                                : NULL;
335
 
 
336
 
        mutex_create_func(mutex,
337
 
# ifdef UNIV_DEBUG
338
 
                          cmutex_name,
339
 
#  ifdef UNIV_SYNC_DEBUG
340
 
                          level,
341
 
#  endif /* UNIV_SYNC_DEBUG */
342
 
# endif /* UNIV_DEBUG */
343
 
                          cfile_name,
344
 
                          cline);
345
 
}
346
 
/******************************************************************//**
347
 
NOTE! Please use the corresponding macro mutex_free(), not directly
348
 
this function!
349
 
Wrapper function for mutex_free_func(). Also destroys the performance
350
 
schema probes when freeing the mutex */
351
 
UNIV_INLINE
352
 
void
353
 
pfs_mutex_free_func(
354
 
/*================*/
355
 
        mutex_t*        mutex)  /*!< in: mutex */
356
 
{
357
 
        if (UNIV_LIKELY(PSI_server && mutex->pfs_psi)) {
358
 
                PSI_server->destroy_mutex(mutex->pfs_psi);
359
 
                mutex->pfs_psi = NULL;
360
 
        }
361
 
 
362
 
        mutex_free_func(mutex);
363
 
}
364
 
 
365
 
#endif /* UNIV_PFS_MUTEX */