Changeset 228 in code for trunk/ring.go


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

Remove channel from ring buffer consumers

This is unused.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ring.go

    r203 r228  
    4040        r.buffer[i] = msg
    4141        r.cur++
    42 
    43         for _, consumer := range r.consumers {
    44                 select {
    45                 case consumer.ch <- struct{}{}:
    46                         // This space is intentionally left blank
    47                 default:
    48                         // The channel already has a pending item
    49                 }
    50         }
    5142}
    5243
     
    5748        if r.closed {
    5849                panic("soju: Ring.Close called twice")
    59         }
    60 
    61         for _, rc := range r.consumers {
    62                 close(rc.ch)
    6350        }
    6451
     
    7259// from the specified history sequence number (see RingConsumer.Close).
    7360//
    74 // The returned channel yields a value each time the consumer has a new message
    75 // available. Consume should be called to drain the consumer.
    76 //
    7761// The consumer can only be used from a single goroutine.
    78 func (r *Ring) NewConsumer(seq *uint64) (*RingConsumer, <-chan struct{}) {
    79         consumer := &RingConsumer{
    80                 ring: r,
    81                 ch:   make(chan struct{}, 1),
    82         }
     62func (r *Ring) NewConsumer(seq *uint64) *RingConsumer {
     63        consumer := &RingConsumer{ring: r}
    8364
    8465        r.lock.Lock()
     
    8869                consumer.cur = r.cur
    8970        }
    90         if consumer.diff() > 0 {
    91                 consumer.ch <- struct{}{}
    92         }
    9371        r.consumers = append(r.consumers, consumer)
    9472        r.lock.Unlock()
    9573
    96         return consumer, consumer.ch
     74        return consumer
    9775}
    9876
     
    10179        ring   *Ring
    10280        cur    uint64
    103         ch     chan struct{}
    10481        closed bool
    10582}
     
    162139        rc.ring.lock.Unlock()
    163140
    164         close(rc.ch)
    165141        rc.closed = true
    166142        return rc.cur
Note: See TracChangeset for help on using the changeset viewer.