private CancellationToken InitializeCancellationToken(DisconnectHandler disconnectHandler, ulong connectionId) { object syncObject = this; #pragma warning disable 420 // Disable warning about volatile by reference since EnsureInitialized does volatile operations return(LazyInitializer.EnsureInitialized(ref _cancellationToken, ref _initialized, ref syncObject, () => disconnectHandler.CreateToken(connectionId))); #pragma warning restore 420 }
internal CancellationToken GetCancellationToken(DisconnectHandler disconnectHandler, ulong connectionId) { // Initialized case is performance sensitive if (_initialized) { return(_cancellationToken); } return(InitializeCancellationToken(disconnectHandler, connectionId)); }
/// <summary> /// Starts the listener and request processing threads. /// </summary> internal void Start(System.Net.HttpListener listener, AppFunc appFunc, IList <IDictionary <string, object> > addresses, IDictionary <string, object> capabilities, LoggerFactoryFunc loggerFactory) { Contract.Assert(_appFunc == null); // Start should only be called once Contract.Assert(listener != null); Contract.Assert(appFunc != null); Contract.Assert(addresses != null); _listener = listener; _appFunc = appFunc; _loggerFactory = loggerFactory; if (_loggerFactory != null) { _logger = _loggerFactory(typeof(OwinHttpListener).FullName); } _basePaths = new List <string>(); foreach (var address in addresses) { // build url from parts string scheme = address.Get <string>("scheme") ?? Uri.UriSchemeHttp; string host = address.Get <string>("host") ?? "localhost"; string port = address.Get <string>("port") ?? "5000"; string path = address.Get <string>("path") ?? string.Empty; // if port is present, add delimiter to value before concatenation if (!string.IsNullOrWhiteSpace(port)) { port = ":" + port; } // Assume http(s)://+:9090/BasePath/, including the first path slash. May be empty. Must end with a slash. if (!path.EndsWith("/", StringComparison.Ordinal)) { // Http.Sys requires that the URL end in a slash path += "/"; } _basePaths.Add(path); // add a server for each url string url = scheme + "://" + host + port + path; _listener.Prefixes.Add(url); } _capabilities = capabilities; _disconnectHandler = new DisconnectHandler(_listener); if (!_listener.IsListening) { _listener.Start(); _disconnectHandler.Initialize(); } OffloadStartNextRequest(); }
private CancellationToken InitializeCancellationToken(DisconnectHandler disconnectHandler, ulong connectionId) { object syncObject = this; #pragma warning disable 420 // Disable warning about volatile by reference since EnsureInitialized does volatile operations return LazyInitializer.EnsureInitialized(ref _cancellationToken, ref _initialized, ref syncObject, () => disconnectHandler.CreateToken(connectionId)); #pragma warning restore 420 }
internal CancellationToken GetCancellationToken(DisconnectHandler disconnectHandler, ulong connectionId) { // Initialized case is performance sensitive if (_initialized) { return _cancellationToken; } return InitializeCancellationToken(disconnectHandler, connectionId); }
/// <summary> /// Starts the listener and request processing threads. /// </summary> internal void Start(System.Net.HttpListener listener, AppFunc appFunc, IList<IDictionary<string, object>> addresses, IDictionary<string, object> capabilities, LoggerFactoryFunc loggerFactory) { Contract.Assert(_appFunc == null); // Start should only be called once Contract.Assert(listener != null); Contract.Assert(appFunc != null); Contract.Assert(addresses != null); _listener = listener; _appFunc = appFunc; _loggerFactory = loggerFactory; if (_loggerFactory != null) { _logger = _loggerFactory(typeof(OwinHttpListener).FullName); } _basePaths = new List<string>(); foreach (var address in addresses) { // build url from parts string scheme = address.Get<string>("scheme") ?? Uri.UriSchemeHttp; string host = address.Get<string>("host") ?? "localhost"; string port = address.Get<string>("port") ?? "5000"; string path = address.Get<string>("path") ?? string.Empty; // if port is present, add delimiter to value before concatenation if (!string.IsNullOrWhiteSpace(port)) { port = ":" + port; } // Assume http(s)://+:9090/BasePath/, including the first path slash. May be empty. Must end with a slash. if (!path.EndsWith("/", StringComparison.Ordinal)) { // Http.Sys requires that the URL end in a slash path += "/"; } _basePaths.Add(path); // add a server for each url string url = scheme + "://" + host + port + path; _listener.Prefixes.Add(url); } _capabilities = capabilities; _disconnectHandler = new DisconnectHandler(_listener); if (!_listener.IsListening) { _listener.Start(); _disconnectHandler.Initialize(); } OffloadStartNextRequest(); }