Skip to content

Commit

Permalink
Merge pull request #1015 from UselessToucan/lockThis
Browse files Browse the repository at this point in the history
Do not use 'this' object for locking
  • Loading branch information
peppy authored Sep 3, 2017
2 parents 2bd341b + ec0fe91 commit 4a0637a
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 2 deletions.
3 changes: 2 additions & 1 deletion osu.Framework/Graphics/Textures/TextureAtlas.cs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ public class TextureAtlas

private readonly bool manualMipmaps;
private readonly All filteringMode;
private readonly object textureRetrievalLock = new object();

public TextureAtlas(int width, int height, bool manualMipmaps = false, All filteringMode = All.Linear)
{
Expand Down Expand Up @@ -94,7 +95,7 @@ private Vector2I findPosition(int width, int height)

internal Texture Add(int width, int height)
{
lock (this)
lock (textureRetrievalLock)
{
if (atlasTexture == null)
Reset();
Expand Down
4 changes: 3 additions & 1 deletion osu.Framework/Input/Handlers/InputHandler.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,12 +19,14 @@ public abstract class InputHandler : IDisposable

protected ConcurrentQueue<InputState> PendingStates = new ConcurrentQueue<InputState>();

private readonly object pendingStatesRetrievalLock = new object();

/// <summary>
/// Retrieve a list of all pending states since the last call to this method.
/// </summary>
public virtual List<InputState> GetPendingStates()
{
lock (this)
lock (pendingStatesRetrievalLock)
{
List<InputState> pending = new List<InputState>();

Expand Down

0 comments on commit 4a0637a

Please sign in to comment.