Skip to content
This repository has been archived by the owner on Jun 16, 2022. It is now read-only.

Commit

Permalink
Removed MqWorker.cs due to new reliance on SmartThreadPool.
Browse files Browse the repository at this point in the history
Updated version to 0.9.
Updated sockets to require minimum of 4 worker threads per connection.
  • Loading branch information
DJGosnell committed Sep 14, 2016
1 parent b2d5181 commit 9bbcf31
Show file tree
Hide file tree
Showing 6 changed files with 21 additions and 180 deletions.
2 changes: 1 addition & 1 deletion src/DtronixMessageQueue.Tests/Rpc/RpcClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ public void Client_calls_proxy_method_and_canceles() {
bool threw = false;
try {
service.LongRunningTask(1, 2, token_source.Token);
} catch (OperationCanceledException ex) {
} catch (OperationCanceledException) {
threw = true;
}

Expand Down
1 change: 0 additions & 1 deletion src/DtronixMessageQueue/DtronixMessageQueue.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,6 @@
</Content>
<None Include="packages.config" />
<Compile Include="MqFrameBuilder.cs" />
<Compile Include="MqWorker.cs" />
<Compile Include="MqPostmaster.cs" />
<Compile Include="IncomingMessageEventArgs.cs" />
<Compile Include="MqClient.cs" />
Expand Down
23 changes: 6 additions & 17 deletions src/DtronixMessageQueue/MqPostmaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,10 @@ namespace DtronixMessageQueue {
public class MqPostmaster<TSession> : IDisposable
where TSession : MqSession<TSession>, new() {

private SmartThreadPool thread_pool;
/// <summary>
/// Internal thread pool for this instance.
/// </summary>
private readonly SmartThreadPool thread_pool;

private class WorkerInfo {

Expand All @@ -24,11 +27,6 @@ public enum WorkerType {
public WorkerType Type;
}

/// <summary>
/// Internal worker to review the current work being done.
/// </summary>
private readonly MqWorker supervisor;

/// <summary>
/// Dictionary to prevent multiple writes occurring on the same session concurrently.
/// </summary>
Expand All @@ -54,24 +52,15 @@ public enum WorkerType {
/// </summary>
private readonly MqSocketConfig config;

private CancellationTokenSource cancellation_token_source = new CancellationTokenSource();
private readonly CancellationTokenSource cancellation_token_source = new CancellationTokenSource();

/// <summary>
/// Creates a new postmaster instance to handle reading and writing of all sessions.
/// </summary>
public MqPostmaster(MqSocketConfig config) {
this.config = config;

// Add a supervisor to review when it is needed to increase or decrease the worker numbers.
//supervisor = new MqWorker(SupervisorWork, "postmaster_supervisor");

// Create one reader and one writer workers to start off with.



//supervisor.Start();

thread_pool = new SmartThreadPool(config.IdleWorkerTimeout, config.MaxReadWriteWorkers);
thread_pool = new SmartThreadPool(config.IdleWorkerTimeout, config.MaxReadWriteWorkers, 4);

var writer_info = new WorkerInfo {
Type = WorkerInfo.WorkerType.Writer,
Expand Down
16 changes: 12 additions & 4 deletions src/DtronixMessageQueue/MqSocketConfig.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
using DtronixMessageQueue.Socket;
using System;
using DtronixMessageQueue.Socket;

namespace DtronixMessageQueue {
public class MqSocketConfig : SocketConfig {
private int max_read_write_workers = 4;

/// <summary>
/// Max size of the frame. Needs to be equal or smaller than SendAndReceiveBufferSize.
Expand All @@ -25,13 +27,19 @@ public class MqSocketConfig : SocketConfig {


/// <summary>
/// (Server)
/// (Server/Client)
/// Max number of workers used to read/write.
/// Minimum of 4 required.
/// </summary>
/// <remarks>
/// Value of 20 would make a maximum of 20 readers and 20 writers. Total of 40 workers.
/// Writers and readers share the total thread count specified here.
/// </remarks>
public int MaxReadWriteWorkers { get; set; } = 20;
public int MaxReadWriteWorkers {
get { return max_read_write_workers; }
set {
max_read_write_workers = Math.Max(4, value);
}
}


/// <summary>
Expand Down
155 changes: 0 additions & 155 deletions src/DtronixMessageQueue/MqWorker.cs

This file was deleted.

4 changes: 2 additions & 2 deletions src/DtronixMessageQueue/Properties/AssemblyInfo.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,5 +35,5 @@
// by using the '*' as shown below:
// [assembly: AssemblyVersion("1.0.*")]

[assembly: AssemblyVersion("0.8.0.0")]
[assembly: AssemblyFileVersion("0.8.0.0")]
[assembly: AssemblyVersion("0.9.0.0")]
[assembly: AssemblyFileVersion("0.9.0.0")]

0 comments on commit 9bbcf31

Please sign in to comment.