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

Commit

Permalink
Adding the timing group for the communication system.
Browse files Browse the repository at this point in the history
references issue #2
  • Loading branch information
pvandervelde committed Dec 4, 2013
1 parent f2c9e5d commit 5176cbf
Show file tree
Hide file tree
Showing 7 changed files with 33 additions and 14 deletions.
17 changes: 17 additions & 0 deletions src/nuclei.communication/CommunicationConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
//-----------------------------------------------------------------------

using System;
using Nuclei.Diagnostics.Profiling;

namespace Nuclei.Communication
{
Expand Down Expand Up @@ -77,5 +78,21 @@ internal static class CommunicationConstants
/// The version of the communication system.
/// </summary>
public static readonly Version CommunicationVersion = new Version(1, 0, 0, 0);

/// <summary>
/// The timing group used for the profiling of the communication system.
/// </summary>
private static readonly TimingGroup s_TimingGroup = new TimingGroup();

/// <summary>
/// Gets the timing group used for the profiling of the communication system.
/// </summary>
internal static TimingGroup TimingGroup
{
get
{
return s_TimingGroup;
}
}
}
}
10 changes: 6 additions & 4 deletions src/nuclei.communication/CommunicationLayer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,7 @@ public void SignIn()
return;
}

using (m_Diagnostics.Profiler.Measure("CommunicationLayer: Signing in"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "CommunicationLayer: Signing in"))
{
// Always open our own channels so that the message processors and the handshake protocol
// are all created and initialized
Expand Down Expand Up @@ -327,7 +327,7 @@ public void SignOut()
return;
}

using (m_Diagnostics.Profiler.Measure("CommunicationLayer: signing out"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "CommunicationLayer: signing out"))
{
// Stop discovering other services. We just stopped caring.
foreach (var source in m_DiscoverySources)
Expand Down Expand Up @@ -467,7 +467,9 @@ public void SendMessageTo(EndpointId endpoint, ICommunicationMessage message)
Lokad.Enforce.Argument(() => message);
}

using (m_Diagnostics.Profiler.Measure("CommunicationLayer: sending message without waiting for response"))
using (m_Diagnostics.Profiler.Measure(
CommunicationConstants.TimingGroup,
"CommunicationLayer: sending message without waiting for response"))
{
var connection = RetrieveEndpointConnection(endpoint);
if (connection == null)
Expand Down Expand Up @@ -527,7 +529,7 @@ public Task<ICommunicationMessage> SendMessageAndWaitForResponse(EndpointId endp
Lokad.Enforce.Argument(() => message);
}

using (m_Diagnostics.Profiler.Measure("CommunicationLayer: sending message and waiting for response"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "CommunicationLayer: sending message and waiting for response"))
{
var connection = RetrieveEndpointConnection(endpoint);
if (connection == null)
Expand Down
2 changes: 1 addition & 1 deletion src/nuclei.communication/DataHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ public void ProcessData(DataTransferMessage message)
"Received data stream from {0}.",
message.SendingEndpoint));

using (m_Diagnostics.Profiler.Measure("Processing incoming data stream"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Processing incoming data stream"))
{
Tuple<string, TaskCompletionSource<FileInfo>> pair = null;
lock (m_Lock)
Expand Down
6 changes: 3 additions & 3 deletions src/nuclei.communication/MessageHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ public void ProcessMessage(ICommunicationMessage message)
Lokad.Enforce.Argument(() => message);
}

using (m_Diagnostics.Profiler.Measure("MessageHandler: processing message"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "MessageHandler: processing message"))
{
// First check that the message isn't a response
if (!message.InResponseTo.Equals(MessageId.None))
Expand All @@ -193,7 +193,7 @@ public void ProcessMessage(ICommunicationMessage message)
message.Id,
message.InResponseTo));

using (m_Diagnostics.Profiler.Measure("Processing response message"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Processing response message"))
{
TaskCompletionSource<ICommunicationMessage> source = null;
lock (m_Lock)
Expand Down Expand Up @@ -225,7 +225,7 @@ public void ProcessMessage(ICommunicationMessage message)
return;
}

using (m_Diagnostics.Profiler.Measure("Using message filters"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Using message filters"))
{
// The message isn't a response so go to the filters
// First copy the filters and their associated actions so that we can
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,7 @@ public void Invoke(ICommunicationMessage message)
return;
}

using (m_Diagnostics.Profiler.Measure("Endpoint trying to connect"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Endpoint trying to connect"))
{
m_HandShakeHandler.ContinueHandshakeWith(
new ChannelConnectionInformation(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ public void Invoke(ICommunicationMessage message)

try
{
using (var interval = m_Diagnostics.Profiler.Measure("Raise notification"))
using (var interval = m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Raise notification"))
{
var type = ProxyExtensions.ToType(invocation.Type);
var notificationSet = m_AvailableProxies.NotificationsFor(msg.OriginatingEndpoint, type);
Expand Down
8 changes: 4 additions & 4 deletions src/nuclei.communication/RemoteEndpointProxyHub.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ internal abstract class RemoteEndpointProxyHub<TProxyObject> where TProxyObject

private void HandleEndpointSignIn(object sender, EndpointSignInEventArgs eventArgs)
{
using (m_Diagnostics.Profiler.Measure("Received endpoint information"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Received endpoint information"))
{
var endpoint = eventArgs.ConnectionInformation.Id;

Expand Down Expand Up @@ -165,7 +165,7 @@ private void HandleEndpointSignIn(object sender, EndpointSignInEventArgs eventAr
{
if (proxyList.Count > 0)
{
using (m_Diagnostics.Profiler.Measure("Notifying of new endpoint"))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Notifying of new endpoint"))
{
RaiseOnEndpointSignedIn(endpoint, proxyList);
}
Expand All @@ -176,7 +176,7 @@ private void HandleEndpointSignIn(object sender, EndpointSignInEventArgs eventAr

private void HandleEndpointSignOut(object sender, EndpointSignedOutEventArgs eventArgs)
{
using (m_Diagnostics.Profiler.Measure("Endpoint disconnected - removing proxies."))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Endpoint disconnected - removing proxies."))
{
lock (m_Lock)
{
Expand Down Expand Up @@ -209,7 +209,7 @@ private void HandleEndpointSignOut(object sender, EndpointSignedOutEventArgs eve
}
}

using (m_Diagnostics.Profiler.Measure("Notifying of proxy removal."))
using (m_Diagnostics.Profiler.Measure(CommunicationConstants.TimingGroup, "Notifying of proxy removal."))
{
RaiseOnEndpointSignedOff(eventArgs.Endpoint);
}
Expand Down

0 comments on commit 5176cbf

Please sign in to comment.