// StartBufferFactory must be called after the cration of BufferFactory
// and before the others functions.
352204
func (bf *BufferFactory) StartBufferFactory() error {
	if bf.NumBuffersPerSize <= 0 {
		return e.New("NumBuffersPerSize must be greater than zero")
	}
	if bf.MinBuffers < 0 {
		return e.New("MinBuffers must be greater or equal to zero")
	}
	if bf.MaxBuffers <= 0 {
		return e.New("MaxBuffers must be greater than zero")
	}
	if bf.MinBufferSize <= 0 {
		return e.New("MinBufferSize must be greater than zero")
	}
	if bf.MaxBufferSize <= 0 {
		return e.New("MinBufferSize must be greater than zero")
	}
	bf.Buffers = NewBuffers(bf.NumBuffersPerSize, bf.MaxBuffers)
	for i := 0; i < bf.MinBuffers; i++ {
		bf.InsertInit(make([]byte, 0, bf.MinBufferSize))
	}
	bf.Buffers.ResetCounters()
	bf.chclose = make(chan struct{})
	if bf.Reposition != 0 {
		go func() {
			for {
				select {
				case <-bf.chclose:
					return
				case <-time.After(bf.Reposition):
					d := bf.MinBuffers - bf.NumBuffers()
					if d > 0 {
						size := bf.MinBufferSize
						avg := int(math.Ceil(bf.GetStats().Average()))
						if avg > size && avg <= bf.MaxBufferSize {
							size = avg
						}
						for i := 0; i < d; i++ {
							bf.InsertInit(make([]byte, 0, size))
							bf.reposition++
						}
					}
				}
			}
		}()
	}
	return nil
}
791822
func (f *FileRotator) flushBuffer() error {
	f.bufLock.Lock()
	defer f.bufLock.Unlock()
	if f.bufw != nil {
		return f.bufw.Flush()
	}
	return nil
}
984962
func EnableBufferedLogging() {
	writer, shutdown, done := NewAutoFlushingBufferedWriter(ErrorWriter(), loggingFrequency)
	stdErrLoggingShutdown = shutdown
	stdErrLoggingShutdownDone = done
	logBackend := logging.NewLogBackend(writer, "", 0)
	logging.SetBackend(logBackend)
}
1167339
func (d *DRV2605LDriver) Start() (err error) {
	if err := d.initialize(); err != nil {
		return err
	}
	return nil
}
1083786
func (i *BatchIndexer) start() error {
	defer close(i.closed)
	t := time.NewTicker(1 * time.Second)
	for {
		select {
		case d := <-i.docs:
			// add doc to buffer
			_, err := i.addInternal(d)
			if err != nil {
				log.Printf("err=%q", err)
			}
			i.checkFlush()
		case <-t.C:
			// index
			i.checkFlush()
		case c := <-i.doFlush:
			c <- i.flush()
		case <-i.doClose:
			// should stop indexing
			return i.flush()
		}
	}
}
851252
func (lib *Lib) MakeBufferString(content string) (*Buffer, error) {
	return lib.MakeBufferBytes([]byte(content))
}
1031987
func (e *endpoint) updateSndBufferUsage(v int) {
	e.sndBufMu.Lock()
	notify := e.sndBufUsed >= e.sndBufSize>>1
	e.sndBufUsed -= v
	// We only notify when there is half the sndBufSize available after
	// a full buffer event occurs. This ensures that we don't wake up
	// writers to queue just 1-2 segments and go back to sleep.
	notify = notify && e.sndBufUsed < e.sndBufSize>>1
	e.sndBufMu.Unlock()

	if notify {
		e.waiterQueue.Notify(waiter.EventOut)
	}
}
1349969
func Factory() (QFactory, error) {
	name, err := config.GetString("queue")
	if err != nil {
		name = "rabbitmq"
	}
	if f, ok := factories[name]; ok {
		return f, nil
	}
	return nil, fmt.Errorf("Queue %q is not known.", name)
}
1077770
func (w *spanWorker) newBuffer() {
	for {
		select {
		// check if the sink is closing and return if so
		// reading from a.closing will only return a value if the a.closing channel is closed
		// nothing should ever write into it
		case <-w.closing:
			// signal that the worker is done
			w.done <- true
			return
		case msg := <-w.input:
			// process the Datapoint Message
			w.bufferFunc(msg)
		}
	}
}
907886
func (bf *BufferFactory) RequestBuffer(size int) *bytes.Buffer {
	buf := bf.Request(size)
	return bytes.NewBuffer(buf[:0])
}
1125308
func AddrsFactory(factory config.AddrsFactory) Option {
	return func(cfg *Config) error {
		if cfg.AddrsFactory != nil {
			return fmt.Errorf("cannot specify multiple address factories")
		}
		cfg.AddrsFactory = factory
		return nil
	}
}
840459
func newBuffer() *buffer {
	e := new(element)
	b := &buffer{
		Cond: newCond(),
		head: e,
		tail: e,
	}
	return b
}
13940
func NewBufferStore(r Retriever, cap int) *BufferStore {
	if cap <= 0 {
		cap = DefaultTxnMembufCap
	}
	return &BufferStore{
		r:         r,
		MemBuffer: &lazyMemBuffer{cap: cap},
	}
}
1000581
func (n *Driver) Start() (err error) {
	go func() {
		for {
			buff := make([]byte, 1024)
			_, err := n.adaptor().sp.Read(buff[:])
			if err != nil {
				n.Publish(n.Event("error"), err)
			} else {
				n.parse(bytes.NewBuffer(buff))
			}
		}
	}()
	return
}
945132
func (this *MirrorMaker) Start() {
	this.initializeMessageChannels()
	this.startConsumers()
	this.startProducers()
	<-this.stopped
}
1290942
func (c *Configuration) DeleteBuffer(size uint32) *Configuration {
	c.deleteBuffer = int(size)
	return c
}
1132059
func (uvm *UtilityVM) Start() (err error) {
	op := "uvm::Start"
	log := logrus.WithFields(logrus.Fields{
		logfields.UVMID: uvm.id,
	})
	log.Debug(op + " - Begin Operation")
	defer func() {
		if err != nil {
			log.Data[logrus.ErrorKey] = err
			log.Error(op + " - End Operation - Error")
		} else {
			log.Debug(op + " - End Operation - Success")
		}
	}()

	if uvm.outputListener != nil {
		ctx, cancel := context.WithCancel(context.Background())
		go processOutput(ctx, uvm.outputListener, uvm.outputProcessingDone, uvm.outputHandler)
		uvm.outputProcessingCancel = cancel
		uvm.outputListener = nil
	}
	return uvm.hcsSystem.Start()
}