~skinny.moey/drizzle/innodb-replication_tests

« back to all changes in this revision

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

  • Committer: Joseph Daly
  • Date: 2010-12-02 00:57:45 UTC
  • mfrom: (1802.1.164 staging)
  • Revision ID: skinny.moey@gmail.com-20101202005745-z3duxvi5chvouf7h
merge trunk

Show diffs side-by-side

added added

removed removed

Lines of Context:
625
625
        rw_x_exit_count++;
626
626
#endif
627
627
}
 
628
 
 
629
#ifdef UNIV_PFS_RWLOCK
 
630
 
 
631
/******************************************************************//**
 
632
Performance schema instrumented wrap function for rw_lock_create_func().
 
633
NOTE! Please use the corresponding macro rw_lock_create(), not directly
 
634
this function! */
 
635
UNIV_INLINE
 
636
void
 
637
pfs_rw_lock_create_func(
 
638
/*====================*/
 
639
        mysql_pfs_key_t key,            /*!< in: key registered with
 
640
                                        performance schema */
 
641
        rw_lock_t*      lock,           /*!< in: pointer to memory */
 
642
# ifdef UNIV_DEBUG
 
643
#  ifdef UNIV_SYNC_DEBUG
 
644
        ulint           level,          /*!< in: level */
 
645
#  endif /* UNIV_SYNC_DEBUG */
 
646
        const char*     cmutex_name,    /*!< in: mutex name */
 
647
# endif /* UNIV_DEBUG */
 
648
        const char*     cfile_name,     /*!< in: file name where created */
 
649
        ulint           cline)          /*!< in: file line where created */
 
650
{
 
651
        /* Initialize the rwlock for performance schema */
 
652
        lock->pfs_psi = (PSI_server && PFS_IS_INSTRUMENTED(key))
 
653
                                ? PSI_server->init_rwlock(key, lock)
 
654
                                : NULL;
 
655
 
 
656
        /* The actual function to initialize an rwlock */
 
657
        rw_lock_create_func(lock,
 
658
# ifdef UNIV_DEBUG
 
659
#  ifdef UNIV_SYNC_DEBUG
 
660
                            level,
 
661
#  endif /* UNIV_SYNC_DEBUG */
 
662
                            cmutex_name,
 
663
# endif /* UNIV_DEBUG */
 
664
                            cfile_name,
 
665
                            cline);
 
666
}
 
667
/******************************************************************//**
 
668
Performance schema instrumented wrap function for rw_lock_x_lock_func()
 
669
NOTE! Please use the corresponding macro rw_lock_x_lock(), not directly
 
670
this function! */
 
671
UNIV_INLINE
 
672
void
 
673
pfs_rw_lock_x_lock_func(
 
674
/*====================*/
 
675
        rw_lock_t*      lock,   /*!< in: pointer to rw-lock */
 
676
        ulint           pass,   /*!< in: pass value; != 0, if the lock will
 
677
                                be passed to another thread to unlock */
 
678
        const char*     file_name,/*!< in: file name where lock requested */
 
679
        ulint           line)   /*!< in: line where requested */
 
680
{
 
681
        struct PSI_rwlock_locker* locker = NULL;
 
682
 
 
683
        /* Record the entry of rw x lock request in performance schema */
 
684
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
685
                locker = PSI_server->get_thread_rwlock_locker(
 
686
                        lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
 
687
 
 
688
                if (locker) {
 
689
                        PSI_server->start_rwlock_wrwait(locker,
 
690
                                                        file_name, line);
 
691
                }
 
692
        }
 
693
 
 
694
        rw_lock_x_lock_func(lock, pass, file_name, line);
 
695
 
 
696
        if (locker) {
 
697
                PSI_server->end_rwlock_wrwait(locker, 0);
 
698
        }
 
699
}
 
700
/******************************************************************//**
 
701
Performance schema instrumented wrap function for
 
702
rw_lock_x_lock_func_nowait()
 
703
NOTE! Please use the corresponding macro rw_lock_x_lock_func(),
 
704
not directly this function!
 
705
@return TRUE if success */
 
706
UNIV_INLINE
 
707
ibool
 
708
pfs_rw_lock_x_lock_func_nowait(
 
709
/*===========================*/
 
710
        rw_lock_t*      lock,   /*!< in: pointer to rw-lock */
 
711
        const char*     file_name,/*!< in: file name where lock
 
712
                                requested */
 
713
        ulint           line)   /*!< in: line where requested */
 
714
{
 
715
        struct PSI_rwlock_locker* locker = NULL;
 
716
        ibool   ret;
 
717
 
 
718
        /* Record the entry of rw x lock request in performance schema */
 
719
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
720
                locker = PSI_server->get_thread_rwlock_locker(
 
721
                        lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
 
722
 
 
723
                if (locker) {
 
724
                        PSI_server->start_rwlock_wrwait(locker,
 
725
                                                        file_name, line);
 
726
                }
 
727
        }
 
728
 
 
729
        ret = rw_lock_x_lock_func_nowait(lock, file_name, line);
 
730
 
 
731
        if (locker) {
 
732
                PSI_server->end_rwlock_wrwait(locker, 0);
 
733
        }
 
734
 
 
735
        return(ret);
 
736
}
 
737
/******************************************************************//**
 
738
Performance schema instrumented wrap function for rw_lock_free_func()
 
739
NOTE! Please use the corresponding macro rw_lock_free(), not directly
 
740
this function! */
 
741
UNIV_INLINE
 
742
void
 
743
pfs_rw_lock_free_func(
 
744
/*==================*/
 
745
        rw_lock_t*      lock)   /*!< in: pointer to rw-lock */
 
746
{
 
747
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
748
                PSI_server->destroy_rwlock(lock->pfs_psi);
 
749
                lock->pfs_psi = NULL;
 
750
        }
 
751
 
 
752
        rw_lock_free_func(lock);
 
753
}
 
754
/******************************************************************//**
 
755
Performance schema instrumented wrap function for rw_lock_s_lock_func()
 
756
NOTE! Please use the corresponding macro rw_lock_s_lock(), not
 
757
directly this function! */
 
758
UNIV_INLINE
 
759
void
 
760
pfs_rw_lock_s_lock_func(
 
761
/*====================*/
 
762
        rw_lock_t*      lock,   /*!< in: pointer to rw-lock */
 
763
        ulint           pass,   /*!< in: pass value; != 0, if the
 
764
                                lock will be passed to another
 
765
                                thread to unlock */
 
766
        const char*     file_name,/*!< in: file name where lock
 
767
                                requested */
 
768
        ulint           line)   /*!< in: line where requested */
 
769
{
 
770
        struct PSI_rwlock_locker* locker = NULL;
 
771
 
 
772
        /* Instrumented to inform we are aquiring a shared rwlock */
 
773
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
774
                locker = PSI_server->get_thread_rwlock_locker(
 
775
                        lock->pfs_psi, PSI_RWLOCK_READLOCK);
 
776
                if (locker) {
 
777
                        PSI_server->start_rwlock_rdwait(locker,
 
778
                                                        file_name, line);
 
779
                }
 
780
        }
 
781
 
 
782
        rw_lock_s_lock_func(lock, pass, file_name, line);
 
783
 
 
784
        if (locker) {
 
785
                PSI_server->end_rwlock_rdwait(locker, 0);
 
786
        }
 
787
}
 
788
/******************************************************************//**
 
789
Performance schema instrumented wrap function for rw_lock_s_lock_func()
 
790
NOTE! Please use the corresponding macro rw_lock_s_lock(), not
 
791
directly this function!
 
792
@return TRUE if success */
 
793
UNIV_INLINE
 
794
ibool
 
795
pfs_rw_lock_s_lock_low(
 
796
/*===================*/
 
797
        rw_lock_t*      lock,   /*!< in: pointer to rw-lock */
 
798
        ulint           pass,   /*!< in: pass value; != 0, if the
 
799
                                lock will be passed to another
 
800
                                thread to unlock */
 
801
        const char*     file_name, /*!< in: file name where lock requested */
 
802
        ulint           line)   /*!< in: line where requested */
 
803
{
 
804
 
 
805
        struct PSI_rwlock_locker* locker = NULL;
 
806
        ibool   ret;
 
807
 
 
808
        /* Instrumented to inform we are aquiring a shared rwlock */
 
809
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
810
                locker = PSI_server->get_thread_rwlock_locker(
 
811
                        lock->pfs_psi, PSI_RWLOCK_READLOCK);
 
812
                if (locker) {
 
813
                        PSI_server->start_rwlock_rdwait(locker,
 
814
                                                        file_name, line);
 
815
                }
 
816
        }
 
817
 
 
818
        ret = rw_lock_s_lock_low(lock, pass, file_name, line);
 
819
 
 
820
        if (locker) {
 
821
                PSI_server->end_rwlock_rdwait(locker, 0);
 
822
        }
 
823
 
 
824
        return(ret);
 
825
}
 
826
 
 
827
/******************************************************************//**
 
828
Performance schema instrumented wrap function for rw_lock_x_unlock_func()
 
829
NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly
 
830
this function! */
 
831
UNIV_INLINE
 
832
void
 
833
pfs_rw_lock_x_unlock_func(
 
834
/*======================*/
 
835
#ifdef UNIV_SYNC_DEBUG
 
836
        ulint           pass,   /*!< in: pass value; != 0, if the
 
837
                                lock may have been passed to another
 
838
                                thread to unlock */
 
839
#endif
 
840
        rw_lock_t*      lock)   /*!< in/out: rw-lock */
 
841
{
 
842
        /* Inform performance schema we are unlocking the lock */
 
843
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
844
                struct PSI_thread*      thread;
 
845
                thread = PSI_server->get_thread();
 
846
                if (thread) {
 
847
                        PSI_server->unlock_rwlock(thread, lock->pfs_psi);
 
848
                }
 
849
        }
 
850
 
 
851
        rw_lock_x_unlock_func(
 
852
#ifdef UNIV_SYNC_DEBUG
 
853
                pass,
 
854
#endif
 
855
                lock);
 
856
}
 
857
 
 
858
/******************************************************************//**
 
859
Performance schema instrumented wrap function for rw_lock_s_unlock_func()
 
860
NOTE! Please use the corresponding macro pfs_rw_lock_s_unlock(), not
 
861
directly this function! */
 
862
UNIV_INLINE
 
863
void
 
864
pfs_rw_lock_s_unlock_func(
 
865
/*======================*/
 
866
#ifdef UNIV_SYNC_DEBUG
 
867
        ulint           pass,   /*!< in: pass value; != 0, if the
 
868
                                lock may have been passed to another
 
869
                                thread to unlock */
 
870
#endif
 
871
        rw_lock_t*      lock)   /*!< in/out: rw-lock */
 
872
{
 
873
        /* Inform performance schema we are unlocking the lock */
 
874
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
875
                struct PSI_thread*      thread;
 
876
                thread = PSI_server->get_thread();
 
877
                if (thread) {
 
878
                        PSI_server->unlock_rwlock(thread, lock->pfs_psi);
 
879
                }
 
880
        }
 
881
 
 
882
        rw_lock_s_unlock_func(
 
883
#ifdef UNIV_SYNC_DEBUG
 
884
                pass,
 
885
#endif
 
886
                lock);
 
887
 
 
888
}
 
889
#endif /* UNIV_PFS_RWLOCK */