Skip to content

Commit

Permalink
Waiter abstraction
Browse files Browse the repository at this point in the history
  • Loading branch information
konraddysput committed Feb 5, 2024
1 parent 883b185 commit 718c928
Show file tree
Hide file tree
Showing 7 changed files with 68 additions and 19 deletions.
9 changes: 3 additions & 6 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,8 @@ jobs:

- name: Setup Environment
run: |
mkdir Tmp
mv Editor Tmp/
mv Runtime Tmp/
mv Tests Tmp/
mv package.json Tmp/package.json
mkdir Package
mv Editor Runtime Tests Android iOS Windows package.json Package/
- name: Run Tests
uses: game-ci/[email protected]
Expand All @@ -34,6 +31,6 @@ jobs:
UNITY_SERIAL: ${{ secrets.UNITY_SERIAL }}
with:
packageMode: true
projectPath: Tmp/
projectPath: Package/
testMode: ${{ matrix.testMode }}
unityVersion: 2022.1.11f1
11 changes: 0 additions & 11 deletions .travis.yml

This file was deleted.

4 changes: 2 additions & 2 deletions Runtime/BacktraceClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -839,7 +839,7 @@ private IEnumerator CollectDataAndSend(BacktraceReport report, Action<BacktraceR

if (Database != null && Database.Enabled())
{

yield return WaitForFrame.Wait();
if (EnablePerformanceStatistics)
{
stopWatch.Restart();
Expand Down Expand Up @@ -885,7 +885,7 @@ record = Database.Add(data);
stopWatch.Stop();
queryAttributes["performance.json"] = stopWatch.GetMicroseconds();
}

yield return WaitForFrame.Wait();
if (string.IsNullOrEmpty(json))
{
yield break;
Expand Down
16 changes: 16 additions & 0 deletions Runtime/Model/WaitForFrame.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
using Backtrace.Unity.Model.Waiter;

namespace Backtrace.Unity.Model
{
public class WaitForFrame
{
private static IWaiter _waiter = Application.isBatchMode
? new BatchModeWaiter()
: new EndOfFrameWaiter();

public static IEnumerator Wait()
{
return _waiter.Wait();
}
}
}
17 changes: 17 additions & 0 deletions Runtime/Waiter/BatchModeWaiter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Backtrace.Unity.Extensions;
using Backtrace.Unity.Types;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Backtrace.Unity.Model.Waiter
{
public class BatchModeWaiter : IWaiter
{
public IEnumerator Wait()
{
Debug.Log("Using BatchModeWaiter");
yield return null;
}
}
}
17 changes: 17 additions & 0 deletions Runtime/Waiter/EndOfFrameWaiter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
using Backtrace.Unity.Extensions;
using Backtrace.Unity.Types;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Backtrace.Unity.Model.Waiter
{
public class EndOfFrameWaiter : IWaiter
{
public IEnumerator Wait()
{
Debug.Log("Using EndOfFrameWaiter");
yield return new WaitForEndOfFrame();
}
}
}
13 changes: 13 additions & 0 deletions Runtime/Waiter/IWaiter.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
using Backtrace.Unity.Extensions;
using Backtrace.Unity.Types;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Backtrace.Unity.Model.Waiter
{
public interface IWaiter
{
public IEnumerator Wait();
}
}

0 comments on commit 718c928

Please sign in to comment.