forked from p53841790/wheat-cache
feat(structure): add channelx
This commit is contained in:
parent
a949ab2edc
commit
f62a59b551
|
@ -51,9 +51,16 @@ func (c *ChannelX) Push(value string) structure.UpdateLength {
|
||||||
|
|
||||||
func (c *ChannelX) Pop() (string, structure.UpdateLength) {
|
func (c *ChannelX) Pop() (string, structure.UpdateLength) {
|
||||||
val := <-c.channel
|
val := <-c.channel
|
||||||
return val.ToString(), structure.UpdateLength(val.GetSize())
|
return val.ToString(), structure.UpdateLength(val.GetSize()) * -1
|
||||||
}
|
}
|
||||||
|
|
||||||
func (c *ChannelX) Length() int {
|
func (c *ChannelX) Length() int {
|
||||||
return len(c.channel)
|
return len(c.channel)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (c *ChannelX) CLean() structure.UpdateLength {
|
||||||
|
c.channel = make(chan *structure.Value, cap(c.channel))
|
||||||
|
up := c.sizeByte
|
||||||
|
c.sizeByte = 0
|
||||||
|
return structure.UpdateLength(up) * -1
|
||||||
|
}
|
||||||
|
|
|
@ -73,4 +73,5 @@ type ChannelXInterface interface {
|
||||||
Push(value string) UpdateLength
|
Push(value string) UpdateLength
|
||||||
Pop() (string, UpdateLength)
|
Pop() (string, UpdateLength)
|
||||||
Length() int
|
Length() int
|
||||||
|
Clean() UpdateLength
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue