From 9a4ddc4193d612cfaa53789ad13899f897f1defb Mon Sep 17 00:00:00 2001 From: James Watson Date: Mon, 5 Sep 2016 00:11:11 +0100 Subject: [PATCH] Support passing IThreadFactory instances to the Aeron.Context to use when constructing the conductor thread. --- src/Adaptive.Aeron/Aeron.cs | 23 ++++++++++++++++++++++- 1 file changed, 22 insertions(+), 1 deletion(-) diff --git a/src/Adaptive.Aeron/Aeron.cs b/src/Adaptive.Aeron/Aeron.cs index aa14d100..1fa392c4 100644 --- a/src/Adaptive.Aeron/Aeron.cs +++ b/src/Adaptive.Aeron/Aeron.cs @@ -135,7 +135,7 @@ public Subscription AddSubscription(string channel, int streamId) private Aeron Start() { - AgentRunner.StartOnThread(_conductorRunner); + AgentRunner.StartOnThread(_conductorRunner, _ctx.ThreadFactory()); return this; } @@ -168,6 +168,7 @@ public class Context : IDisposable private UnsafeBuffer _countersMetaDataBuffer; private UnsafeBuffer _countersValuesBuffer; private MapMode _imageMapMode = MapMode.ReadOnly; + private IThreadFactory threadFactory = new DefaultThreadFactory(); /// /// The top level Aeron directory used for communication between a Media Driver and client. @@ -524,6 +525,26 @@ public Context ImageMapMode(MapMode imageMapMode) return this; } + /// + /// Specify the thread factory to use when starting the conductor thread. + /// + /// thread factory to construct the thread. + /// this for a fluent API. + public Context ThreadFactory(IThreadFactory threadFactory) + { + this.threadFactory = threadFactory; + return this; + } + + /// + /// The thread factory to be use to construct the conductor thread + /// + /// the specified thread factory of if none is provided. + public IThreadFactory ThreadFactory() + { + return threadFactory; + } + /// /// Return the timeout, in milliseconds, that this client will use to determine if a /// has active subscribers or not.