Skip to content

Commit

Permalink
avoid locking on this reference (Azure#382)
Browse files Browse the repository at this point in the history
  • Loading branch information
bojcicm authored and xinchen10 committed Aug 26, 2019
1 parent 7fe8bc7 commit 9b40a87
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
3 changes: 2 additions & 1 deletion src/Connection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ enum State
ITransport writer;
Pump reader;
HeartBeat heartBeat;
private readonly object lockObject = new object();

Connection(Address address, ushort channelMax, uint maxFrameSize)
{
Expand Down Expand Up @@ -137,7 +138,7 @@ public IHandler Handler

object ThisLock
{
get { return this; }
get { return this.lockObject; }
}

#if NETFX || NETFX40 || DOTNET || NETFX_CORE || WINDOWS_STORE || WINDOWS_PHONE
Expand Down
3 changes: 2 additions & 1 deletion src/Link.cs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ public abstract partial class Link : AmqpObject
readonly OnAttached onAttached;
LinkState state;
bool detach;
private readonly object lockObject = new object();

/// <summary>
/// Initializes the link.
Expand Down Expand Up @@ -96,7 +97,7 @@ public Session Session

internal object ThisLock
{
get { return this; }
get { return this.lockObject; }
}

internal bool IsDetaching
Expand Down
4 changes: 3 additions & 1 deletion src/Session.cs
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,8 @@ enum State
Link[] localLinks;
Link[] remoteLinks;
State state;
private readonly object lockObject = new object();


// incoming flow control
SequenceNumber incomingDeliveryId;
Expand Down Expand Up @@ -104,7 +106,7 @@ public Connection Connection

object ThisLock
{
get { return this; }
get { return this.lockObject; }
}

internal ushort Channel
Expand Down

0 comments on commit 9b40a87

Please sign in to comment.