Changeset 232 in code for trunk/ring.go
- Timestamp:
- Apr 6, 2020, 4:33:26 PM (5 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/ring.go
r231 r232 71 71 // RingConsumer is a ring buffer consumer. 72 72 type RingConsumer struct { 73 ring *Ring 74 cur uint64 75 closed bool 73 ring *Ring 74 cur uint64 76 75 } 77 76 … … 87 86 // message is returned if no message is available. 88 87 func (rc *RingConsumer) Peek() *irc.Message { 89 if rc.closed {90 panic("soju: RingConsumer.Peek called after Close")91 }92 93 88 diff := rc.diff() 94 89 if diff == 0 { … … 116 111 return msg 117 112 } 118 119 // Close stops consuming messages. The consumer channel will be closed. The120 // current history sequence number is returned. It can be provided later as an121 // argument to Ring.NewConsumer to resume the message stream.122 func (rc *RingConsumer) Close() uint64 {123 for i := range rc.ring.consumers {124 if rc.ring.consumers[i] == rc {125 rc.ring.consumers = append(rc.ring.consumers[:i], rc.ring.consumers[i+1:]...)126 break127 }128 }129 130 rc.closed = true131 return rc.cur132 }
Note:
See TracChangeset
for help on using the changeset viewer.