github.com/haraldrudell/parl@v0.4.176/nb-chan-thread-type.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 "github.com/haraldrudell/parl/sets" 9 10 const ( 11 // NBChanAlways configures NBChan to always have a thread 12 // - benefit: for empty NBChan, Send/SendMany to channel receive is faster due to avoiding thread launch 13 // - cost: a thread is always running instad of only running when NBChan non-empty 14 // - cost: Close or CloseNow must be invoked to shutdown NBChan 15 NBChanAlways NBChanThreadType = iota + 1 16 // NBChanNone configures no thread. 17 // - benefit: lower cpu 18 // - cost: data can only be received using [NBChan.Get] 19 NBChanNone 20 // NBChanOnDemand configures on-demand thread 21 NBChanOnDemand 22 ) 23 24 // NBChanThreadType defines how NBChan is operating 25 // - [NBChanAlways] [NBChanNone] or on-demand thread 26 type NBChanThreadType uint8 27 28 func (n NBChanThreadType) String() (s string) { 29 return nbChanThreadTypeSet.StringT(n) 30 } 31 32 // set for [NBChanThreadType] 33 var nbChanThreadTypeSet = sets.NewSet[NBChanThreadType]([]sets.SetElement[NBChanThreadType]{ 34 {ValueV: NBChanAlways, Name: "alwaysCh"}, 35 {ValueV: NBChanNone, Name: "noCh"}, 36 })