Sets up a context with an old stream
and a blas handle
@return the cuda context
as setup for cublas usage
168588
public static CudaContext getBlasContext() {
        CudaContext context = (CudaContext) AtomicAllocator.getInstance().getDeviceContext().getContext();
        //context.syncOldStream(false);
        return context;
    }
1172561
private ThreadContextDescriptor appendInflowContext() throws WorkCompletedException {
        ThreadContextDescriptor merged = threadContextDescriptor.clone();
        Set<String> inflowContext = new HashSet<String>();

        // WorkContext
        if (workContexts != null)
            for (WorkContext workContext : workContexts)
                if (workContext instanceof HintsContext) {
                    if (hintsContextSetupFailure != null)
                        throw contextSetupFailure(workContext, WorkContextErrorCodes.CONTEXT_SETUP_FAILED, hintsContextSetupFailure);
                } else {
                    JCAContextProvider provider = bootstrapContext.getJCAContextProvider(workContext.getClass());
                    if (provider == null)
                        throw contextSetupFailure(workContext, WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE, null);
                    else {
                        ThreadContext context;
                        try {
                            context = provider.getInflowContext(workContext, executionProperties);
                        } catch (Throwable x) {
                            throw contextSetupFailure(workContext, WorkContextErrorCodes.CONTEXT_SETUP_FAILED, x);
                        }
                        String workContextProviderName = bootstrapContext.getJCAContextProviderName(workContext.getClass());
                        if (!inflowContext.add(workContextProviderName))
                            throw contextSetupFailure(workContext, WorkContextErrorCodes.DUPLICATE_CONTEXTS, null);
                        merged.set(workContextProviderName, context);
                    }
                }

        // ExecutionContext
        if (executionContext != null)
            if (inflowContext.isEmpty() && (executionContext.getXid() != null || executionContext.getTransactionTimeout() != WorkManager.UNKNOWN)) {
                JCAContextProvider provider = bootstrapContext.getJCAContextProvider(TransactionContext.class);
                if (provider == null)
                    throw contextSetupFailure(executionContext, WorkContextErrorCodes.UNSUPPORTED_CONTEXT_TYPE, null);
                ThreadContext context;
                try {
                    context = provider.getInflowContext(executionContext, executionProperties);
                } catch (Throwable x) {
                    throw contextSetupFailure(executionContext, WorkContextErrorCodes.CONTEXT_SETUP_FAILED, x);
                }
                String executionContextHandlerName = bootstrapContext.getJCAContextProviderName(TransactionContext.class);
                merged.set(executionContextHandlerName, context);
            } // else - already checked for this error condition earlier

        return merged;
    }
1236416
@SuppressWarnings("unchecked")
    private ThreadContextDescriptor captureRaThreadContext(WSContextService contextSvc) {
        Map<String, String> execProps = new HashMap<String, String>();
        execProps.put(WSContextService.DEFAULT_CONTEXT, WSContextService.ALL_CONTEXT_TYPES);
        execProps.put(WSContextService.REQUIRE_AVAILABLE_APP, "false");

        return contextSvc.captureThreadContext(execProps);
    }
1227747
public function initializeStreamWrapper()
    {
        $stream = new Stream('accompli', array(
                'recipe' => realpath(__DIR__.'/Resources/recipe'),
            ), false);

        StreamManager::create()->registerStream($stream);
    }
767076
public ELContext setELContext(ELContext context) {
        ELContext prev = elContext;
        elContext = new StandardELContext(context);
        return prev;
    }
1037664
public static int cusolverRfSetupHost(
        int n, 
        int nnzA, 
        Pointer h_csrRowPtrA, 
        Pointer h_csrColIndA, 
        Pointer h_csrValA, 
        int nnzL, 
        Pointer h_csrRowPtrL, 
        Pointer h_csrColIndL, 
        Pointer h_csrValL, 
        int nnzU, 
        Pointer h_csrRowPtrU, 
        Pointer h_csrColIndU, 
        Pointer h_csrValU, 
        Pointer h_P, 
        Pointer h_Q, 
        /** Output */
        cusolverRfHandle handle)
    {
        return checkResult(cusolverRfSetupHostNative(n, nnzA, h_csrRowPtrA, h_csrColIndA, h_csrValA, nnzL, h_csrRowPtrL, h_csrColIndL, h_csrValL, nnzU, h_csrRowPtrU, h_csrColIndU, h_csrValU, h_P, h_Q, handle));
    }
1155188
def cublasSetStream(handle, id):
    

    status = _libcublas.cublasSetStream_v2(handle, id)
    cublasCheckStatus(status)
756595
protected ContextualStorage getContextualStorage(boolean createIfNotExist, String clientWindowFlowId)
    {
        //FacesContext facesContext = FacesContext.getCurrentInstance();
        //String clientWindowFlowId = getCurrentClientWindowFlowId(facesContext);
        if (clientWindowFlowId == null)
        {
            throw new ContextNotActiveException("FlowScopedContextImpl: no current active flow");
        }

        if (createIfNotExist)
        {
            return getFlowScopeBeanHolder().getContextualStorage(beanManager, clientWindowFlowId);
        }
        else
        {
            return getFlowScopeBeanHolder().getContextualStorageNoCreate(beanManager, clientWindowFlowId);
        }
    }
1020443
public static RpcInvokeContext getContext() {
        RpcInvokeContext context = LOCAL.get();
        if (context == null) {
            context = new RpcInvokeContext();
            LOCAL.set(context);
        }
        return context;
    }
309492
def context
      c = Thread.current.thread_variable_get(NAME)

      if c.nil?
        c = if Thread.current.thread_variable_get(STACK_NAME)
          flatten(stack)
        else
          Hash.new
        end
        Thread.current.thread_variable_set(NAME, c)
      end

      return c
    end
355107
public function getStreamContextOptions()
    {
        $options = [];
        $context = $this->getStreamContext();
        if ($context !== null) {
            $options = stream_context_get_options($context);
        }
        return $options;
    }
195162
public function getStreamContext()
    {
        return ($this->getSoapClient() && isset($this->getSoapClient()->_stream_context) && is_resource($this->getSoapClient()->_stream_context)) ? $this->getSoapClient()->_stream_context : null;
    }
1331479
public static PageFlowContext getContext() {
        PageFlowContext ctxt = (PageFlowContext) pageflowContext.get();
        if (ctxt == null) {
            ctxt = new PageFlowContext();
            pageflowContext.set(ctxt);
        }
        return ctxt;
    }
572675
def cudnnSetStream(handle, id):
    

    status = _libcudnn.cudnnSetStream(handle, id)
    cudnnCheckStatus(status)
1255877
public function getStreamContext()
    {
        // set basic stream context configuration
        $config = [
            'tcp' => [
                'method'          => 'GET',
                'user_agent'      => $this->loader->getUserAgent(),
                // ignore errors, handle them manually
                'ignore_errors'   => true,
                'request_fulluri' => true,
                'timeout'         => $this->loader->getTimeout(),
            ],
        ];

        // check and set proxy settings
        $proxy_host = $this->loader->getOption('ProxyHost');
        if (null !== $proxy_host) {
            // check for supported protocol
            $proxy_protocol = $this->loader->getOption('ProxyProtocol');
            if (null !== $proxy_protocol) {
                if (!in_array($proxy_protocol, [self::PROXY_PROTOCOL_HTTP, self::PROXY_PROTOCOL_HTTPS])) {
                    throw new Exception(
                        'Invalid/unsupported value "' . $proxy_protocol . '" for option "ProxyProtocol".',
                        Exception::INVALID_OPTION
                    );
                }
            } else {
                $proxy_protocol = self::PROXY_PROTOCOL_HTTP;
            }

            // prepare port for the proxy server address
            $proxy_port = $this->loader->getOption('ProxyPort');
            if (null !== $proxy_port) {
                $proxy_port = ':' . $proxy_port;
            } else {
                $proxy_port = '';
            }

            // check auth settings
            $proxy_auth = $this->loader->getOption('ProxyAuth');
            if (null !== $proxy_auth) {
                if (!in_array($proxy_auth, [self::PROXY_AUTH_BASIC])) {
                    throw new Exception(
                        'Invalid/unsupported value "' . $proxy_auth . '" for option "ProxyAuth".',
                        Exception::INVALID_OPTION
                    );
                }
            } else {
                $proxy_auth = self::PROXY_AUTH_BASIC;
            }

            // set proxy server address
            $config['http']['proxy'] = 'tcp://' . $proxy_host . $proxy_port;
            // full uri required by some proxy servers
            $config['http']['request_fulluri'] = true;

            // add authorization header if required
            $proxy_user = $this->loader->getOption('ProxyUser');
            if (null !== $proxy_user) {
                $proxy_password = $this->loader->getOption('ProxyPassword');
                if (null === $proxy_password) {
                    $proxy_password = '';
                }
                $auth                     = base64_encode($proxy_user . ':' . $proxy_password);
                $config['http']['header'] = 'Proxy-Authorization: Basic ' . $auth;
            }
        }

        return stream_context_create($config);
    }
970192
protected function getStreamContext()
    {
        $ctx = stream_context_create();

        stream_context_set_option($ctx, "ssl", "local_cert", $this->pem);
        if (strlen($this->passphrase)) {
            stream_context_set_option($ctx, "ssl", "passphrase", $this->passphrase);
        }

        return $ctx;
    }
543593
public static RpcInternalContext getContext() {
        RpcInternalContext context = LOCAL.get();
        if (context == null) {
            context = new RpcInternalContext();
            LOCAL.set(context);
        }
        return context;
    }