// NewDropout creates a new Dropout with the given context (handle, states, etc)
189776
func NewDropoutWithContext(dropout float64, handle *Context, states Memory, stateSizeInBytes uintptr, seed uint64) (retVal *Dropout, err error) {
	if retVal, err = NewDropout(dropout); err != nil {
		return
	}
	err = retVal.Use(handle, states, stateSizeInBytes, seed)
	return
}
160093
func NewContext() *Context {
	ctx, cancel := context.WithCancel(context.Background())
	sctx := &Context{
		values:      make(map[fmt.Stringer]interface{}),
		sessionVars: variable.NewSessionVars(),
		ctx:         ctx,
		cancel:      cancel,
	}
	sctx.sessionVars.InitChunkSize = 2
	sctx.sessionVars.MaxChunkSize = 32
	sctx.sessionVars.StmtCtx.TimeZone = time.UTC
	sctx.sessionVars.GlobalVarsAccessor = variable.NewMockGlobalAccessor()
	return sctx
}
661371
func New() context.Handler {
	return func(ctx context.Context) {
		defer func() {
			if err := recover(); err != nil {
				if ctx.IsStopped() {
					return
				}

				var stacktrace string
				for i := 1; ; i++ {
					_, f, l, got := runtime.Caller(i)
					if !got {
						break

					}

					stacktrace += fmt.Sprintf("%s:%d\n", f, l)
				}

				// when stack finishes
				logMessage := fmt.Sprintf("Recovered from a route's Handler('%s')\n", ctx.HandlerName())
				logMessage += fmt.Sprintf("At Request: %s\n", getRequestLogs(ctx))
				logMessage += fmt.Sprintf("Trace: %s\n", err)
				logMessage += fmt.Sprintf("\n%s", stacktrace)
				ctx.Application().Logger().Warn(logMessage)

				ctx.StatusCode(500)
				ctx.StopExecution()
			}
		}()

		ctx.Next()
	}
}
333413
func NewEventHandler(projector Projector, repo eh.ReadWriteRepo) *EventHandler {
	return &EventHandler{
		projector: projector,
		repo:      repo,
	}
}
259097
func (opt Options) New(c context.Context) output.Output {
	o := fileOutput{
		Context: c,
		Options: &opt,
		streams: map[types.StreamPath]*stream{},
	}
	if opt.Track {
		o.et = &output.EntryTracker{}
	}
	return &o
}
26749
func New(ctx context.Context, c Config) output.Output {
	o := pubSubOutput{
		Config: &c,
	}
	o.bufferPool.New = func() interface{} { return &buffer{} }

	if c.Track {
		o.et = &output.EntryTracker{}
	}

	o.Context = log.SetField(ctx, "pubsub", &o)
	return &o
}
329840
func DropReason(reason uint8) string {
	if err, ok := errors[reason]; ok {
		return err
	}
	return fmt.Sprintf("%d", reason)
}
858504
func NewLoop(loopData *LoopData, scope app.EventScope) *Loop {
	loop := &Loop{
		scope:    scope,
		loopData: loopData,
	}
	loop.loopData.chans.dirChan = make(chan string, ChanSize)
	loop.loopData.chans.fileChan = make(chan string, ChanSize)
	return loop
}
929496
func newOutputOption(name, description string, f outputFactory) *outputOption {
	return &outputOption{
		FlagOption: multiflag.FlagOption{
			Name:        name,
			Description: description,
		},
		factory: f,
	}
}
1273028
func NewHandler(opts ...handlerOption) (*Handler, error) {
	handler := &Handler{
		logger:       logger.NopLogger,
		closeTimeout: time.Second * 30,
	}
	handler.Handler = newRouter(handler)
	handler.populateValidators()

	for _, opt := range opts {
		err := opt(handler)
		if err != nil {
			return nil, errors.Wrap(err, "applying option")
		}
	}

	if handler.api == nil {
		return nil, errors.New("must pass OptHandlerAPI")
	}

	if handler.ln == nil {
		return nil, errors.New("must pass OptHandlerListener")
	}

	handler.server = &http.Server{Handler: handler}

	return handler, nil
}
537483
func (n *DropNotify) DumpInfo(data []byte) {
	fmt.Printf("xx drop (%s) flow %#x to endpoint %d, identity %d->%d: %s\n",
		api.DropReason(n.SubType), n.Hash, n.DstID, n.SrcLabel, n.DstLabel,
		GetConnectionSummary(data[DropNotifyLen:]))
}
1291536
func (c *Client) NewEvent() *Event {
	c.ensureTransmission()
	c.ensureBuilder()
	return c.builder.NewEvent()
}
713248
func NewHookContextFacade(st *state.State, unit *state.Unit) (interface{}, error) {
	up, err := st.UnitPayloads(unit)
	if err != nil {
		return nil, errors.Trace(err)
	}
	return NewUnitFacade(up), nil
}
1279774
func (db *DB) DropIndex(name string) error {
	return db.Update(func(tx *Tx) error {
		return tx.DropIndex(name)
	})
}
529766
func (h *BindHandle) AddDropInvalidBindTask(invalidBindRecord *BindRecord) {
	key := invalidBindRecord.OriginalSQL + ":" + invalidBindRecord.Db
	if _, ok := h.invalidBindRecordMap.Value.Load().(map[string]*invalidBindRecordMap)[key]; ok {
		return
	}
	h.invalidBindRecordMap.Lock()
	defer h.invalidBindRecordMap.Unlock()
	if _, ok := h.invalidBindRecordMap.Value.Load().(map[string]*invalidBindRecordMap)[key]; ok {
		return
	}
	newMap := copyInvalidBindRecordMap(h.invalidBindRecordMap.Value.Load().(map[string]*invalidBindRecordMap))
	newMap[key] = &invalidBindRecordMap{
		bindRecord: invalidBindRecord,
	}
	h.invalidBindRecordMap.Store(newMap)
}
372587
func NewEvent(etype, eselector string, efx EventHandler) *Event {
	ex := Event{
		Meta: &domevents.EventMetable{EventType: etype, EventTarget: eselector},
	}

	// wireup the function to get the ev and tree.
	ex.Fx = func(ev domevents.Event) {
		if efx != nil {
			efx(ev, ex.tree)
		}
	}

	return &ex
}
456927
func newContextGroup(ctx context.Context, cf TeardownFunc) ContextGroup {
	ctx, cancel := context.WithCancel(ctx)
	c := &contextGroup{
		ctx:    ctx,
		cancel: cancel,
		closed: make(chan struct{}),
	}
	c.SetTeardown(cf)

	c.Children().Add(1) // initialize with 1. calling Close will decrement it.
	go c.closeOnContextDone()
	return c
}