Skip to content

Commit c13d0eb

Browse files
Reduces check session and set context id redundant calls
* Reduces object allocations.
1 parent 1b410b2 commit c13d0eb

29 files changed

+623
-802
lines changed

src/NHibernate/Async/Engine/ISessionImplementor.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ namespace NHibernate.Engine
2828
{
2929
using System.Threading.Tasks;
3030
using System.Threading;
31+
3132
public partial interface ISessionImplementor
3233
{
3334

src/NHibernate/Async/Event/IEventSource.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public partial interface IEventSource : ISessionImplementor, ISession
3535

3636
/// <summary> Cascade refresh an entity instance</summary>
3737
Task RefreshAsync(object obj, IDictionary refreshedAlready, CancellationToken cancellationToken);
38-
38+
3939
/// <summary> Cascade delete an entity instance</summary>
4040
Task DeleteAsync(string entityName, object child, bool isCascadeDeleteEnabled, ISet<object> transientEntities, CancellationToken cancellationToken);
4141
}

src/NHibernate/Async/Id/Insert/AbstractSelectingDelegate.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ public async Task<object> PerformInsertAsync(SqlCommandInfo insertSql, ISessionI
5454
}
5555

5656
var selectSql = SelectSQL;
57-
using (new SessionIdLoggingContext(session.SessionId))
57+
using (session.BeginProcess())
5858
{
5959
try
6060
{
@@ -124,4 +124,4 @@ protected internal virtual Task BindParametersAsync(ISessionImplementor session,
124124
}
125125
}
126126
}
127-
}
127+
}

src/NHibernate/Async/Impl/AbstractSessionImpl.cs

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ public virtual async Task<IList> ListAsync(IQueryExpression queryExpression, Que
5858
public virtual async Task<IList<T>> ListAsync<T>(IQueryExpression query, QueryParameters parameters, CancellationToken cancellationToken)
5959
{
6060
cancellationToken.ThrowIfCancellationRequested();
61-
using (new SessionIdLoggingContext(SessionId))
61+
using (BeginProcess())
6262
{
6363
var results = new List<T>();
6464
await (ListAsync(query, parameters, results, cancellationToken)).ConfigureAwait(false);
@@ -69,7 +69,7 @@ public virtual async Task<IList<T>> ListAsync<T>(IQueryExpression query, QueryPa
6969
public virtual async Task<IList<T>> ListAsync<T>(CriteriaImpl criteria, CancellationToken cancellationToken)
7070
{
7171
cancellationToken.ThrowIfCancellationRequested();
72-
using (new SessionIdLoggingContext(SessionId))
72+
using (BeginProcess())
7373
{
7474
var results = new List<T>();
7575
await (ListAsync(criteria, results, cancellationToken)).ConfigureAwait(false);
@@ -82,7 +82,7 @@ public virtual async Task<IList<T>> ListAsync<T>(CriteriaImpl criteria, Cancella
8282
public virtual async Task<IList> ListAsync(CriteriaImpl criteria, CancellationToken cancellationToken)
8383
{
8484
cancellationToken.ThrowIfCancellationRequested();
85-
using (new SessionIdLoggingContext(SessionId))
85+
using (BeginProcess())
8686
{
8787
var results = new List<object>();
8888
await (ListAsync(criteria, results, cancellationToken)).ConfigureAwait(false);
@@ -113,7 +113,7 @@ public async Task<IList> ListFilterAsync(object collection, IQueryExpression que
113113
public virtual async Task<IList> ListAsync(NativeSQLQuerySpecification spec, QueryParameters queryParameters, CancellationToken cancellationToken)
114114
{
115115
cancellationToken.ThrowIfCancellationRequested();
116-
using (new SessionIdLoggingContext(SessionId))
116+
using (BeginProcess())
117117
{
118118
var results = new List<object>();
119119
await (ListAsync(spec, queryParameters, results, cancellationToken)).ConfigureAwait(false);
@@ -124,7 +124,7 @@ public virtual async Task<IList> ListAsync(NativeSQLQuerySpecification spec, Que
124124
public virtual async Task ListAsync(NativeSQLQuerySpecification spec, QueryParameters queryParameters, IList results, CancellationToken cancellationToken)
125125
{
126126
cancellationToken.ThrowIfCancellationRequested();
127-
using (new SessionIdLoggingContext(SessionId))
127+
using (BeginProcess())
128128
{
129129
var query = new SQLCustomQuery(
130130
spec.SqlQueryReturns,
@@ -138,7 +138,7 @@ public virtual async Task ListAsync(NativeSQLQuerySpecification spec, QueryParam
138138
public virtual async Task<IList<T>> ListAsync<T>(NativeSQLQuerySpecification spec, QueryParameters queryParameters, CancellationToken cancellationToken)
139139
{
140140
cancellationToken.ThrowIfCancellationRequested();
141-
using (new SessionIdLoggingContext(SessionId))
141+
using (BeginProcess())
142142
{
143143
var results = new List<T>();
144144
await (ListAsync(spec, queryParameters, results, cancellationToken)).ConfigureAwait(false);
@@ -151,7 +151,7 @@ public virtual async Task<IList<T>> ListAsync<T>(NativeSQLQuerySpecification spe
151151
public virtual async Task<IList<T>> ListCustomQueryAsync<T>(ICustomQuery customQuery, QueryParameters queryParameters, CancellationToken cancellationToken)
152152
{
153153
cancellationToken.ThrowIfCancellationRequested();
154-
using (new SessionIdLoggingContext(SessionId))
154+
using (BeginProcess())
155155
{
156156
var results = new List<T>();
157157
await (ListCustomQueryAsync(customQuery, queryParameters, results, cancellationToken)).ConfigureAwait(false);
@@ -170,7 +170,7 @@ public virtual async Task<IList<T>> ListCustomQueryAsync<T>(ICustomQuery customQ
170170
protected async Task AfterOperationAsync(bool success, CancellationToken cancellationToken)
171171
{
172172
cancellationToken.ThrowIfCancellationRequested();
173-
using (new SessionIdLoggingContext(SessionId))
173+
using (BeginContext())
174174
{
175175
if (!ConnectionManager.IsInActiveTransaction)
176176
{

src/NHibernate/Async/Impl/MultiCriteriaImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public partial class MultiCriteriaImpl : IMultiCriteria
3333
public async Task<IList> ListAsync(CancellationToken cancellationToken = default(CancellationToken))
3434
{
3535
cancellationToken.ThrowIfCancellationRequested();
36-
using (new SessionIdLoggingContext(session.SessionId))
36+
using (session.BeginProcess())
3737
{
3838
bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable;
3939

src/NHibernate/Async/Impl/MultiQueryImpl.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ public partial class MultiQueryImpl : IMultiQuery
3939
public async Task<IList> ListAsync(CancellationToken cancellationToken = default(CancellationToken))
4040
{
4141
cancellationToken.ThrowIfCancellationRequested();
42-
using (new SessionIdLoggingContext(session.SessionId))
42+
using (session.BeginProcess())
4343
{
4444
bool cacheable = session.Factory.Settings.IsQueryCacheEnabled && isCacheable;
4545
combinedParameters = CreateCombinedQueryParameters();

0 commit comments

Comments
 (0)