Changeset 232 in code for trunk/ring.go


Ignore:
Timestamp:
Apr 6, 2020, 4:33:26 PM (5 years ago)
Author:
contact
Message:

Remove RingConsumer.Close

This is now unused.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ring.go

    r231 r232  
    7171// RingConsumer is a ring buffer consumer.
    7272type RingConsumer struct {
    73         ring   *Ring
    74         cur    uint64
    75         closed bool
     73        ring *Ring
     74        cur  uint64
    7675}
    7776
     
    8786// message is returned if no message is available.
    8887func (rc *RingConsumer) Peek() *irc.Message {
    89         if rc.closed {
    90                 panic("soju: RingConsumer.Peek called after Close")
    91         }
    92 
    9388        diff := rc.diff()
    9489        if diff == 0 {
     
    116111        return msg
    117112}
    118 
    119 // Close stops consuming messages. The consumer channel will be closed. The
    120 // current history sequence number is returned. It can be provided later as an
    121 // 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                         break
    127                 }
    128         }
    129 
    130         rc.closed = true
    131         return rc.cur
    132 }
Note: See TracChangeset for help on using the changeset viewer.