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

Commit

Permalink
Performance tests are now functioning.
Browse files Browse the repository at this point in the history
Finally fixed long standing bug for issue #1.
  • Loading branch information
DJGosnell committed Sep 8, 2016
1 parent 1572d82 commit 6cc402c
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public RpcPerformanceTest(string[] args) {
Port = 2828
};

RpcSingleProcessTest(1000, 10, config, RpcTestType.NoRetrun);
RpcSingleProcessTest(100000, 4, config, RpcTestType.NoRetrun);
}


Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ class TestService : MarshalByRefObject, ITestService {

public void TestNoReturn() {
var number = Interlocked.Increment(ref call_count);
Console.Write(number + " ");
//Console.Write(number + " ");
VerifyComplete();

}
Expand Down
2 changes: 2 additions & 0 deletions DtronixMessageQueue.Tests/MqClientTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public MqClientTests(ITestOutputHelper output) : base(output) {
[Theory]
[InlineData(1, false)]
[InlineData(1, true)]
[InlineData(100, true)]
[InlineData(1000, true)]
public void Client_should_send_data_to_server(int number, bool validate) {
var message_source = GenerateRandomMessage(4, 50);
int received_messages = 0;
Expand Down
2 changes: 2 additions & 0 deletions DtronixMessageQueue.Tests/MqServerTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@ public MqServerTests(ITestOutputHelper output) : base(output) {
[Theory]
[InlineData(1, false)]
[InlineData(1, true)]
[InlineData(100, true)]
[InlineData(1000, true)]
public void Server_should_send_data_to_client(int number, bool validate) {
var message_source = GenerateRandomMessage(4, 50);

Expand Down
17 changes: 13 additions & 4 deletions DtronixMessageQueue/MqPostmaster.cs
Original file line number Diff line number Diff line change
Expand Up @@ -155,9 +155,14 @@ public void CreateWriteWorker() {
worker.StartIdle();
while (write_operations.TryTake(out session, 60000, worker.Token)) {
worker.StartWork();
session.ProcessOutbox();

if (session.ProcessOutbox()) {
write_operations.TryAdd(session);
} else {
ongoing_write_operations.TryRemove(session, out out_session);
}

worker.StartIdle();
ongoing_write_operations.TryRemove(session, out out_session);
}
} catch (ThreadAbortException) {
} catch (Exception) {
Expand Down Expand Up @@ -186,9 +191,13 @@ public void CreateReadWorker() {
worker.StartIdle();
while (read_operations.TryTake(out session, 60000, worker.Token)) {
worker.StartWork();
session.ProcessIncomingQueue();
if (session.ProcessIncomingQueue()) {
read_operations.TryAdd(session);
} else {
ongoing_read_operations.TryRemove(session, out out_session);
}

worker.StartIdle();
ongoing_read_operations.TryRemove(session, out out_session);

}
} catch (ThreadAbortException) {
Expand Down
23 changes: 16 additions & 7 deletions DtronixMessageQueue/MqSession.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,7 +115,8 @@ private void SendBufferQueue(Queue<byte[]> buffer_queue, int length) {
/// <summary>
/// Internally called method by the Postmaster on a different thread to send all messages in the outbox.
/// </summary>
internal void ProcessOutbox() {
/// <returns>True if messages were sent. False if nothing was sent.</returns>
internal bool ProcessOutbox() {
MqMessage result;
var length = 0;
var buffer_queue = new Queue<byte[]>();
Expand All @@ -139,16 +140,20 @@ internal void ProcessOutbox() {
}
}

if (buffer_queue.Count > 0) {
// Send the last of the buffer queue.
SendBufferQueue(buffer_queue, length);
if (buffer_queue.Count == 0) {
return false;
}

// Send the last of the buffer queue.
SendBufferQueue(buffer_queue, length);
return true;
}

/// <summary>
/// Internal method called by the Postmaster on a different thread to process all bytes in the inbox.
/// </summary>
internal void ProcessIncomingQueue() {
/// <returns>True if incoming queue was processed; False if nothing was available for process.</returns>
internal bool ProcessIncomingQueue() {
if (message == null) {
message = new MqMessage();
}
Expand Down Expand Up @@ -201,9 +206,13 @@ internal void ProcessIncomingQueue() {
}
//Postmaster.SignalReadComplete(this);

if (messages != null) {
OnIncomingMessage(this, new IncomingMessageEventArgs<TSession>(messages, (TSession)this));
if (messages == null) {
return false;
}

OnIncomingMessage(this, new IncomingMessageEventArgs<TSession>(messages, (TSession)this));
return true;

}

/// <summary>
Expand Down

0 comments on commit 6cc402c

Please sign in to comment.