~drizzle-trunk/drizzle/development

« back to all changes in this revision

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

  • Committer: Monty Taylor
  • Date: 2011-02-13 17:26:39 UTC
  • mfrom: (2157.2.2 give-in-to-pkg-config)
  • mto: This revision was merged to the branch mainline in revision 2166.
  • Revision ID: mordred@inaugust.com-20110213172639-nhy7i72sfhoq13ms
Merged in pkg-config fixes.

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
18
18
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
19
19
 
20
20
You should have received a copy of the GNU General Public License along with
21
 
this program; if not, write to the Free Software Foundation, Inc., 59 Temple
22
 
Place, Suite 330, Boston, MA 02111-1307 USA
 
21
this program; if not, write to the Free Software Foundation, Inc., 51 Franklin
 
22
St, Fifth Floor, Boston, MA 02110-1301 USA
23
23
 
24
24
*****************************************************************************/
25
25
 
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
        PSI_rwlock_locker_state         state;
 
683
 
 
684
        /* Record the entry of rw x lock request in performance schema */
 
685
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
686
                locker = PSI_server->get_thread_rwlock_locker(
 
687
                        &state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
 
688
 
 
689
                if (locker) {
 
690
                        PSI_server->start_rwlock_wrwait(locker,
 
691
                                                        file_name, line);
 
692
                }
 
693
        }
 
694
 
 
695
        rw_lock_x_lock_func(lock, pass, file_name, line);
 
696
 
 
697
        if (locker) {
 
698
                PSI_server->end_rwlock_wrwait(locker, 0);
 
699
        }
 
700
}
 
701
/******************************************************************//**
 
702
Performance schema instrumented wrap function for
 
703
rw_lock_x_lock_func_nowait()
 
704
NOTE! Please use the corresponding macro rw_lock_x_lock_func(),
 
705
not directly this function!
 
706
@return TRUE if success */
 
707
UNIV_INLINE
 
708
ibool
 
709
pfs_rw_lock_x_lock_func_nowait(
 
710
/*===========================*/
 
711
        rw_lock_t*      lock,   /*!< in: pointer to rw-lock */
 
712
        const char*     file_name,/*!< in: file name where lock
 
713
                                requested */
 
714
        ulint           line)   /*!< in: line where requested */
 
715
{
 
716
        struct PSI_rwlock_locker*       locker = NULL;
 
717
        PSI_rwlock_locker_state         state;
 
718
        ibool   ret;
 
719
 
 
720
        /* Record the entry of rw x lock request in performance schema */
 
721
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
722
                locker = PSI_server->get_thread_rwlock_locker(
 
723
                        &state, lock->pfs_psi, PSI_RWLOCK_WRITELOCK);
 
724
 
 
725
                if (locker) {
 
726
                        PSI_server->start_rwlock_wrwait(locker,
 
727
                                                        file_name, line);
 
728
                }
 
729
        }
 
730
 
 
731
        ret = rw_lock_x_lock_func_nowait(lock, file_name, line);
 
732
 
 
733
        if (locker) {
 
734
                PSI_server->end_rwlock_wrwait(locker, 0);
 
735
        }
 
736
 
 
737
        return(ret);
 
738
}
 
739
/******************************************************************//**
 
740
Performance schema instrumented wrap function for rw_lock_free_func()
 
741
NOTE! Please use the corresponding macro rw_lock_free(), not directly
 
742
this function! */
 
743
UNIV_INLINE
 
744
void
 
745
pfs_rw_lock_free_func(
 
746
/*==================*/
 
747
        rw_lock_t*      lock)   /*!< in: pointer to rw-lock */
 
748
{
 
749
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
750
                PSI_server->destroy_rwlock(lock->pfs_psi);
 
751
                lock->pfs_psi = NULL;
 
752
        }
 
753
 
 
754
        rw_lock_free_func(lock);
 
755
}
 
756
/******************************************************************//**
 
757
Performance schema instrumented wrap function for rw_lock_s_lock_func()
 
758
NOTE! Please use the corresponding macro rw_lock_s_lock(), not
 
759
directly this function! */
 
760
UNIV_INLINE
 
761
void
 
762
pfs_rw_lock_s_lock_func(
 
763
/*====================*/
 
764
        rw_lock_t*      lock,   /*!< in: pointer to rw-lock */
 
765
        ulint           pass,   /*!< in: pass value; != 0, if the
 
766
                                lock will be passed to another
 
767
                                thread to unlock */
 
768
        const char*     file_name,/*!< in: file name where lock
 
769
                                requested */
 
770
        ulint           line)   /*!< in: line where requested */
 
771
{
 
772
        struct PSI_rwlock_locker*       locker = NULL;
 
773
        PSI_rwlock_locker_state         state;
 
774
 
 
775
        /* Instrumented to inform we are aquiring a shared rwlock */
 
776
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
777
                locker = PSI_server->get_thread_rwlock_locker(
 
778
                        &state, lock->pfs_psi, PSI_RWLOCK_READLOCK);
 
779
                if (locker) {
 
780
                        PSI_server->start_rwlock_rdwait(locker,
 
781
                                                        file_name, line);
 
782
                }
 
783
        }
 
784
 
 
785
        rw_lock_s_lock_func(lock, pass, file_name, line);
 
786
 
 
787
        if (locker) {
 
788
                PSI_server->end_rwlock_rdwait(locker, 0);
 
789
        }
 
790
}
 
791
/******************************************************************//**
 
792
Performance schema instrumented wrap function for rw_lock_s_lock_func()
 
793
NOTE! Please use the corresponding macro rw_lock_s_lock(), not
 
794
directly this function!
 
795
@return TRUE if success */
 
796
UNIV_INLINE
 
797
ibool
 
798
pfs_rw_lock_s_lock_low(
 
799
/*===================*/
 
800
        rw_lock_t*      lock,   /*!< in: pointer to rw-lock */
 
801
        ulint           pass,   /*!< in: pass value; != 0, if the
 
802
                                lock will be passed to another
 
803
                                thread to unlock */
 
804
        const char*     file_name, /*!< in: file name where lock requested */
 
805
        ulint           line)   /*!< in: line where requested */
 
806
{
 
807
        struct PSI_rwlock_locker*       locker = NULL;
 
808
        PSI_rwlock_locker_state         state;
 
809
        ibool   ret;
 
810
 
 
811
        /* Instrumented to inform we are aquiring a shared rwlock */
 
812
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
813
                locker = PSI_server->get_thread_rwlock_locker(
 
814
                        &state, lock->pfs_psi, PSI_RWLOCK_READLOCK);
 
815
                if (locker) {
 
816
                        PSI_server->start_rwlock_rdwait(locker,
 
817
                                                        file_name, line);
 
818
                }
 
819
        }
 
820
 
 
821
        ret = rw_lock_s_lock_low(lock, pass, file_name, line);
 
822
 
 
823
        if (locker) {
 
824
                PSI_server->end_rwlock_rdwait(locker, 0);
 
825
        }
 
826
 
 
827
        return(ret);
 
828
}
 
829
 
 
830
/******************************************************************//**
 
831
Performance schema instrumented wrap function for rw_lock_x_unlock_func()
 
832
NOTE! Please use the corresponding macro rw_lock_x_unlock(), not directly
 
833
this function! */
 
834
UNIV_INLINE
 
835
void
 
836
pfs_rw_lock_x_unlock_func(
 
837
/*======================*/
 
838
#ifdef UNIV_SYNC_DEBUG
 
839
        ulint           pass,   /*!< in: pass value; != 0, if the
 
840
                                lock may have been passed to another
 
841
                                thread to unlock */
 
842
#endif
 
843
        rw_lock_t*      lock)   /*!< in/out: rw-lock */
 
844
{
 
845
        /* Inform performance schema we are unlocking the lock */
 
846
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
847
                PSI_server->unlock_rwlock(lock->pfs_psi);
 
848
        }
 
849
 
 
850
        rw_lock_x_unlock_func(
 
851
#ifdef UNIV_SYNC_DEBUG
 
852
                pass,
 
853
#endif
 
854
                lock);
 
855
}
 
856
 
 
857
/******************************************************************//**
 
858
Performance schema instrumented wrap function for rw_lock_s_unlock_func()
 
859
NOTE! Please use the corresponding macro pfs_rw_lock_s_unlock(), not
 
860
directly this function! */
 
861
UNIV_INLINE
 
862
void
 
863
pfs_rw_lock_s_unlock_func(
 
864
/*======================*/
 
865
#ifdef UNIV_SYNC_DEBUG
 
866
        ulint           pass,   /*!< in: pass value; != 0, if the
 
867
                                lock may have been passed to another
 
868
                                thread to unlock */
 
869
#endif
 
870
        rw_lock_t*      lock)   /*!< in/out: rw-lock */
 
871
{
 
872
        /* Inform performance schema we are unlocking the lock */
 
873
        if (UNIV_LIKELY(PSI_server && lock->pfs_psi)) {
 
874
                PSI_server->unlock_rwlock(lock->pfs_psi);
 
875
        }
 
876
 
 
877
        rw_lock_s_unlock_func(
 
878
#ifdef UNIV_SYNC_DEBUG
 
879
                pass,
 
880
#endif
 
881
                lock);
 
882
 
 
883
}
 
884
#endif /* UNIV_PFS_RWLOCK */