Skip to content

Commit

Permalink
Support passing IThreadFactory instances to the Aeron.Context to use …
Browse files Browse the repository at this point in the history
…when constructing the conductor thread.
  • Loading branch information
JPWatson committed Sep 4, 2016
1 parent b933a07 commit 9a4ddc4
Showing 1 changed file with 22 additions and 1 deletion.
23 changes: 22 additions & 1 deletion src/Adaptive.Aeron/Aeron.cs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ public Subscription AddSubscription(string channel, int streamId)

private Aeron Start()
{
AgentRunner.StartOnThread(_conductorRunner);
AgentRunner.StartOnThread(_conductorRunner, _ctx.ThreadFactory());
return this;
}

Expand Down Expand Up @@ -168,6 +168,7 @@ public class Context : IDisposable
private UnsafeBuffer _countersMetaDataBuffer;
private UnsafeBuffer _countersValuesBuffer;
private MapMode _imageMapMode = MapMode.ReadOnly;
private IThreadFactory threadFactory = new DefaultThreadFactory();

/// <summary>
/// The top level Aeron directory used for communication between a Media Driver and client.
Expand Down Expand Up @@ -524,6 +525,26 @@ public Context ImageMapMode(MapMode imageMapMode)
return this;
}

/// <summary>
/// Specify the thread factory to use when starting the conductor thread.
/// </summary>
/// <param name="threadFactory"> thread factory to construct the thread.</param>
/// <returns> this for a fluent API.</returns>
public Context ThreadFactory(IThreadFactory threadFactory)
{
this.threadFactory = threadFactory;
return this;
}

/// <summary>
/// The thread factory to be use to construct the conductor thread
/// </summary>
/// <returns>the specified thread factory of <see cref="DefaultThreadFactory"/> if none is provided.</returns>
public IThreadFactory ThreadFactory()
{
return threadFactory;
}

/// <summary>
/// Return the timeout, in milliseconds, that this client will use to determine if a <seealso cref="Publication"/>
/// has active subscribers or not.
Expand Down

0 comments on commit 9a4ddc4

Please sign in to comment.