Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions src/Simple.OData.Client.Core/Http/RequestRunner.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,11 @@ public RequestRunner(ISession session)
}
}

public bool WillLock()
{
return (_semaphore != null ? (_semaphore.CurrentCount > 0 ? false : true) : false);
}

public async Task<HttpResponseMessage> ExecuteRequestAsync(ODataRequest request, CancellationToken cancellationToken)
{
if (_maxConcurrentRequests > 0 && _semaphore is not null)
Expand Down
5 changes: 5 additions & 0 deletions src/Simple.OData.Client.Core/IODataClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -606,4 +606,9 @@ public interface IODataClient
Task<T[]> ExecuteActionAsArrayAsync<T>(string actionName, IDictionary<string, object> parameters, CancellationToken cancellationToken);
Task<ODataResponse> GetResponseAsync(ODataRequest request);
Task<ODataResponse> GetResponseAsync(ODataRequest request, CancellationToken cancellationToken);
/// <summary>
/// Tests wether there is any available threads (semaphores) to process.
/// </summary>
/// <returns>true if any call will cause a lock by the call</returns>
bool NextCallWillLock();
}
7 changes: 7 additions & 0 deletions src/Simple.OData.Client.Core/ODataClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -197,4 +197,11 @@ public void UpdateRequestHeaders(Dictionary<string, IEnumerable<string>> headers
}
};
}

/// <summary>
/// Tests wether there is any available threads (semaphores) to process.
/// </summary>
/// <returns>true if any call will cause a lock by the call</returns>
bool IODataClient.NextCallWillLock() => _requestRunner.WillLock();

}