// NewContextWithServerTransportStream creates a new context from ctx and
// attaches stream to it.
//
// This API is EXPERIMENTAL.
182926
func NewContextWithServerTransportStream(ctx context.Context, stream ServerTransportStream) context.Context {
	return context.WithValue(ctx, streamKey{}, stream)
}
983178
func contextTransport(ctx context.Context) http.RoundTripper {
	if client, ok := ctx.Value(HTTPClient).(*http.Client); ok {
		return client.Transport
	}
	return nil
}
864327
func (call *AddLIFFCall) WithContext(ctx context.Context) *AddLIFFCall {
	call.ctx = ctx
	return call
}
546670
func (o *CreateOAuth2ClientParams) WithContext(ctx context.Context) *CreateOAuth2ClientParams {
	o.SetContext(ctx)
	return o
}
990858
func NewContextFromGlobalContext(g *libkb.GlobalContext) *KBFSContext {
	c := &KBFSContext{g: g}
	c.initKBFSSocket()
	return c
}
197461
func NewContext(content []byte) context {
	c := context{remainingLines: strings.Replace(string(content), "\r", "", -1)}
	c.Increment()
	return c
}
762803
func NewContext(d Device, flags ContextFlags) *Ctx {
	var cctx C.CUcontext
	err := result(C.cuCtxCreate(&cctx, C.uint(flags), C.CUdevice(d)))
	if err != nil {
		panic(err)
	}
	ctx := newContext(makeContext(cctx))
	ctx.device = d
	ctx.flags = flags

	errChan := make(chan error)
	go ctx.Run(errChan)
	if err := <-errChan; err != nil {
		panic(err)
	}

	return ctx
}
398284
func (server *Server) ServeCodecWithContext(codec ServerCodec, context interface{}) {
	sending := new(sync.Mutex)
	eof := make(chan struct{})

	stopChans := make(map[uint64]chan struct{})
	var stopChansMtx sync.Mutex

	var contextVal reflect.Value
	if context != nil {
		contextVal = reflect.ValueOf(context)
	} else {
		contextVal = reflect.New(server.contextType)
	}
	for {
		service, mtype, req, argv, replyv, keepReading, err := server.readRequest(codec)
		if err != nil {
			if err == errCloseStream {
				go func() {
					stopChansMtx.Lock()
					stop, ok := stopChans[req.Seq]
					delete(stopChans, req.Seq)
					stopChansMtx.Unlock()
					if !ok {
						return
					}
					close(stop)
				}()
				continue
			}
			if !keepReading {
				break
			}
			// send a response if we actually managed to read a header.
			if req != nil {
				server.sendResponse(sending, req, invalidRequest, codec, err.Error(), true)
				server.freeRequest(req)
			}
			continue
		}

		done := make(chan struct{})
		stop := make(chan struct{})
		stopChansMtx.Lock()
		stopChans[req.Seq] = stop
		stopChansMtx.Unlock()

		go func(seq uint64) {
			<-done
			stopChansMtx.Lock()
			delete(stopChans, seq)
			stopChansMtx.Unlock()
		}(req.Seq)
		go service.call(call{
			server:  server,
			sending: sending,
			mtype:   mtype,
			req:     req,
			argv:    argv,
			replyv:  replyv,
			codec:   codec,
			context: contextVal,
			eof:     eof,
			done:    done,
			stop:    stop,
		})
	}
	close(eof)
	codec.Close()
}
381818
func NewContext(req *http.Request) *Context {
	if ae != nil {
		ctxt := ae.NewContext(req)
		return &Context{ae: ctxt}
	}
	return newContext(req)
}
337113
func (c *Client) WithContext(ctx context.Context) *Client {
	newC := *c
	newC.ctx = ctx
	return &newC
}
744010
func (db *Conn) WithContext(ctx context.Context) *Conn {
	return newConn(ctx, db.baseDB)
}
672830
func (c Client) PutObjectWithContext(ctx context.Context, bucketName, objectName string, reader io.Reader, objectSize int64,
	opts PutObjectOptions) (n int64, err error) {
	err = opts.validate()
	if err != nil {
		return 0, err
	}
	return c.putObjectCommon(ctx, bucketName, objectName, reader, objectSize, opts)
}
1260394
func (sdk *FabricSDK) ChannelContext(channelID string, options ...ContextOption) contextApi.ChannelProvider {

	channelProvider := func() (contextApi.Channel, error) {

		clientCtxProvider := sdk.Context(options...)
		return context.NewChannel(clientCtxProvider, channelID)

	}

	return channelProvider
}
1264423
func NewContext(BlockSize int) *Context {
	return &Context{
		blockSize:    BlockSize,
		uniqueHasher: md5.New(),
	}
}
916691
func NewContext(ctx context.Context) (Reader, context.Context, func()) {
	pr, pw, cancel := pipe()
	ctx = WithProgress(ctx, pw)
	return pr, ctx, cancel
}
254356
func NewContext(ctx context.Context, cfg Etc) context.Context {
	return context.WithValue(ctx, etcKey, cfg)
}
1108955
func NewContextWrap(ctx context.Context, msg string) context.Context {
	logContext, ok := ctx.Value(logContextKey).(string)
	if ok {
		return context.WithValue(ctx, logContextKey, fmt.Sprintf("%s %s", logContext, msg))
	}
	return context.WithValue(ctx, logContextKey, msg)
}