コード例 #1
0
ファイル: sync0rw.c プロジェクト: zhangsong246/mysql-3.23.49
void
rw_lock_create_func(
    /*================*/
    rw_lock_t*	lock,		/* in: pointer to memory */
    char*		cfile_name,	/* in: file name where created */
    ulint		cline)		/* in: file line where created */
{
    /* If this is the very first time a synchronization
    object is created, then the following call initializes
    the sync system. */

    mutex_create(rw_lock_get_mutex(lock));
    mutex_set_level(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);

    lock->mutex.cfile_name = cfile_name;
    lock->mutex.cline = cline;

    rw_lock_set_waiters(lock, 0);
    rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
    lock->writer_count = 0;
    rw_lock_set_reader_count(lock, 0);

    lock->writer_is_wait_ex = FALSE;

    UT_LIST_INIT(lock->debug_list);

    lock->magic_n = RW_LOCK_MAGIC_N;
    lock->level = SYNC_LEVEL_NONE;

    lock->cfile_name = cfile_name;
    lock->cline = cline;

    lock->last_s_file_name = "not yet reserved";
    lock->last_x_file_name = "not yet reserved";
    lock->last_s_line = 0;
    lock->last_x_line = 0;

    mutex_enter(&rw_lock_list_mutex);

    UT_LIST_ADD_FIRST(list, rw_lock_list, lock);

    mutex_exit(&rw_lock_list_mutex);
}
コード例 #2
0
ファイル: sync0rw.c プロジェクト: potkungza/MySQL5.1
void
rw_lock_create_func(
    /*================*/
    rw_lock_t*	lock,		/* in: pointer to memory */
#ifdef UNIV_DEBUG
# ifdef UNIV_SYNC_DEBUG
    ulint		level,		/* in: level */
# endif /* UNIV_SYNC_DEBUG */
    const char*	cmutex_name, 	/* in: mutex name */
#endif /* UNIV_DEBUG */
    const char*	cfile_name,	/* in: file name where created */
    ulint 		cline)		/* in: file line where created */
{
    /* If this is the very first time a synchronization object is
    created, then the following call initializes the sync system. */

    mutex_create(rw_lock_get_mutex(lock), SYNC_NO_ORDER_CHECK);

    lock->mutex.cfile_name = cfile_name;
    lock->mutex.cline = cline;

#if defined UNIV_DEBUG && !defined UNIV_HOTBACKUP
    lock->mutex.cmutex_name = cmutex_name;
    lock->mutex.mutex_type = 1;
#endif /* UNIV_DEBUG && !UNIV_HOTBACKUP */

    rw_lock_set_waiters(lock, 0);
    rw_lock_set_writer(lock, RW_LOCK_NOT_LOCKED);
    lock->writer_count = 0;
    rw_lock_set_reader_count(lock, 0);

    lock->writer_is_wait_ex = FALSE;

#ifdef UNIV_SYNC_DEBUG
    UT_LIST_INIT(lock->debug_list);

    lock->level = level;
#endif /* UNIV_SYNC_DEBUG */

    lock->magic_n = RW_LOCK_MAGIC_N;

    lock->cfile_name = cfile_name;
    lock->cline = (unsigned int) cline;

    lock->last_s_file_name = "not yet reserved";
    lock->last_x_file_name = "not yet reserved";
    lock->last_s_line = 0;
    lock->last_x_line = 0;
    lock->event = os_event_create(NULL);

#ifdef __WIN__
    lock->wait_ex_event = os_event_create(NULL);
#endif

    mutex_enter(&rw_lock_list_mutex);

    if (UT_LIST_GET_LEN(rw_lock_list) > 0) {
        ut_a(UT_LIST_GET_FIRST(rw_lock_list)->magic_n
             == RW_LOCK_MAGIC_N);
    }

    UT_LIST_ADD_FIRST(list, rw_lock_list, lock);

    mutex_exit(&rw_lock_list_mutex);
}