github.com/haraldrudell/parl@v0.4.176/thread-id.go (about)

     1  /*
     2  © 2022–present Harald Rudell <harald.rudell@gmail.com> (https://haraldrudell.github.io/haraldrudell/)
     3  ISC License
     4  */
     5  
     6  package parl
     7  
     8  import "strconv"
     9  
    10  // ThreadID is an opaque type that uniquley identifies a thread, ie. a goroutine.
    11  //   - goid.GoID obtains ThreadID for the executing thread.
    12  //   - in runtime.g, goid is uint64
    13  //   - ThreadID is comparable, ie. can be used as a map key.
    14  //   - ThreadID is fmt.Stringer
    15  //   - ThreadID has IsValid method
    16  type ThreadID uint64
    17  
    18  func (threadID ThreadID) IsValid() (isValid bool) {
    19  	return threadID > 0
    20  }
    21  
    22  func (threadID ThreadID) String() (s string) {
    23  	return strconv.FormatUint(uint64(threadID), 10)
    24  }