Skip to content

Commit

Permalink
Change function taking data from queue.
Browse files Browse the repository at this point in the history
-> TryTake() with timeout => Take()
  • Loading branch information
hyunseok-yang committed Jul 26, 2020
1 parent 0cfebaa commit acd31f7
Showing 1 changed file with 3 additions and 11 deletions.
14 changes: 3 additions & 11 deletions Assets/Scripts/Devices/Device.cs
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,6 @@ void OnDestroy()

public float UpdatePeriod => 1f/updateRate;

public int UpdatePeriodInMillisecond => (int)(UpdatePeriod * SEC2MSEC);

public float TransportingTime => transportingTimeSeconds;

public bool EnableDebugging
Expand Down Expand Up @@ -211,18 +209,12 @@ protected bool PushData()

public MemoryStream PopData()
{
if (memoryStreamOutboundQueue == null)
if (memoryStreamOutboundQueue == null || memoryStreamOutboundQueue.Count == 0)
{
return null;
}

if (memoryStreamOutboundQueue.TryTake(out var item, UpdatePeriodInMillisecond))
{
return item;
}
else
{
return null;
}
var item = memoryStreamOutboundQueue.Take();
return item;
}
}

0 comments on commit acd31f7

Please sign in to comment.