From 5e6e5fec01efe5db13d3b89536ab62952c9e81aa Mon Sep 17 00:00:00 2001 From: Louis DeJardin Date: Mon, 27 Jul 2015 11:40:39 -0700 Subject: [PATCH] Adding an IKestralServerInformation.ThreadCount property Will default to 1 until multi-loop stability is ensured --- src/Kestrel/IKestrelServerInformation.cs | 10 ++++++++++ src/Kestrel/ServerFactory.cs | 2 +- src/Kestrel/ServerInformation.cs | 6 ++++-- 3 files changed, 15 insertions(+), 3 deletions(-) create mode 100644 src/Kestrel/IKestrelServerInformation.cs diff --git a/src/Kestrel/IKestrelServerInformation.cs b/src/Kestrel/IKestrelServerInformation.cs new file mode 100644 index 0000000000..a9fce59d09 --- /dev/null +++ b/src/Kestrel/IKestrelServerInformation.cs @@ -0,0 +1,10 @@ +// Copyright (c) .NET Foundation. All rights reserved. +// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information. + +namespace Kestrel +{ + public interface IKestrelServerInformation + { + int ThreadCount { get; set; } + } +} diff --git a/src/Kestrel/ServerFactory.cs b/src/Kestrel/ServerFactory.cs index ac60b4c4f2..784b1cdbdd 100644 --- a/src/Kestrel/ServerFactory.cs +++ b/src/Kestrel/ServerFactory.cs @@ -38,7 +38,7 @@ namespace Kestrel var disposables = new List(); var information = (ServerInformation)serverInformation; var engine = new KestrelEngine(_libraryManager, _appShutdownService); - engine.Start(Environment.ProcessorCount); + engine.Start(information.ThreadCount == 0 ? 1 : information.ThreadCount); foreach (var address in information.Addresses) { disposables.Add(engine.CreateServer( diff --git a/src/Kestrel/ServerInformation.cs b/src/Kestrel/ServerInformation.cs index dfbde7e91d..a3b770834c 100644 --- a/src/Kestrel/ServerInformation.cs +++ b/src/Kestrel/ServerInformation.cs @@ -8,7 +8,7 @@ using Microsoft.Framework.Configuration; namespace Kestrel { - public class ServerInformation : IServerInformation + public class ServerInformation : IServerInformation, IKestrelServerInformation { public ServerInformation() { @@ -25,7 +25,7 @@ namespace Kestrel foreach (var url in urls.Split(new[] { ';' }, StringSplitOptions.RemoveEmptyEntries)) { var address = ServerAddress.FromUrl(url); - if(address != null) + if (address != null) { Addresses.Add(address); } @@ -41,5 +41,7 @@ namespace Kestrel } public IList Addresses { get; private set; } + + public int ThreadCount { get; set; } } }