github.com/keysonZZZ/kmg@v0.0.0-20151121023212-05317bfd7d39/kmgDebug/sync.go (about)

     1  package kmgDebug
     2  
     3  import (
     4  	"fmt"
     5  	"sync"
     6  )
     7  
     8  type RWMutex struct {
     9  	rw   sync.RWMutex
    10  	Name string
    11  }
    12  
    13  func (rw *RWMutex) RLock() {
    14  	fmt.Println("[RWMutex]", rw.Name, "RLock start")
    15  	rw.rw.RLock()
    16  	fmt.Println("[RWMutex]", rw.Name, "RLock end")
    17  }
    18  func (rw *RWMutex) RUnlock() {
    19  	fmt.Println("[RWMutex]", rw.Name, "RUnlock start")
    20  	rw.rw.RUnlock()
    21  	fmt.Println("[RWMutex]", rw.Name, "RUnlock end")
    22  }
    23  func (rw *RWMutex) Lock() {
    24  	fmt.Println("[RWMutex]", rw.Name, "Lock start")
    25  	rw.rw.Lock()
    26  	fmt.Println("[RWMutex]", rw.Name, "Lock end")
    27  }
    28  func (rw *RWMutex) Unlock() {
    29  	fmt.Println("[RWMutex]", rw.Name, "Unlock start")
    30  	rw.rw.Unlock()
    31  	fmt.Println("[RWMutex]", rw.Name, "Unlock end")
    32  }
    33  
    34  type UselessRWMutex struct{}
    35  
    36  func (rw UselessRWMutex) RLock() {
    37  }
    38  func (rw UselessRWMutex) RUnlock() {
    39  }
    40  func (rw UselessRWMutex) Lock() {
    41  }
    42  func (rw UselessRWMutex) Unlock() {
    43  }