github.com/lmorg/murex@v0.0.0-20240217211045-e081c89cd4ef/lang/process/name.go (about)

     1  package process
     2  
     3  import "sync"
     4  
     5  type Name struct {
     6  	mutex sync.RWMutex
     7  	name  string
     8  }
     9  
    10  func (n *Name) Set(s string) {
    11  	n.mutex.Lock()
    12  	n.name = s
    13  	n.mutex.Unlock()
    14  }
    15  
    16  func (n *Name) SetRune(r []rune) {
    17  	n.mutex.Lock()
    18  	n.name = string(r)
    19  	n.mutex.Unlock()
    20  }
    21  
    22  func (n *Name) String() string {
    23  	n.mutex.RLock()
    24  	s := n.name
    25  	n.mutex.RUnlock()
    26  
    27  	return s
    28  }
    29  
    30  func (n *Name) Append(s string) {
    31  	n.mutex.Lock()
    32  	n.name += s
    33  	n.mutex.Unlock()
    34  }