mirror of
https://github.com/ckaczor/sqltoolsservice.git
synced 2026-01-28 17:24:27 -05:00
Remove extra level of tasks in binding queue (#79)
* Remove extra layer of tasks in binding queue * Change order of assigning result to avoid race condition * Add timeout log for the metadata lock event * Fix test cases
This commit is contained in:
@@ -30,12 +30,12 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
/// <summary>
|
||||
/// Gets or sets the bind operation callback method
|
||||
/// </summary>
|
||||
public Func<IBindingContext, CancellationToken, Task<object>> BindOperation { get; set; }
|
||||
public Func<IBindingContext, CancellationToken, object> BindOperation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the timeout operation to call if the bind operation doesn't finish within timeout period
|
||||
/// </summary>
|
||||
public Func<IBindingContext, Task<object>> TimeoutOperation { get; set; }
|
||||
public Func<IBindingContext, object> TimeoutOperation { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets an event to signal when this queue item has been processed
|
||||
@@ -43,10 +43,9 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
public ManualResetEvent ItemProcessed { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the task that was used to execute this queue item.
|
||||
/// This allows the queuer to retrieve the execution result.
|
||||
/// Gets or sets the result of the queued task
|
||||
/// </summary>
|
||||
public Task<object> ResultsTask { get; set; }
|
||||
public object Result { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets or sets the binding operation timeout in milliseconds
|
||||
@@ -54,13 +53,13 @@ namespace Microsoft.SqlTools.ServiceLayer.LanguageServices
|
||||
public int? BindingTimeout { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts the result of the execution task to type T
|
||||
/// Converts the result of the execution to type T
|
||||
/// </summary>
|
||||
public T GetResultAsT<T>() where T : class
|
||||
{
|
||||
var task = this.ResultsTask;
|
||||
return (task != null && task.IsCompleted && task.Result != null)
|
||||
? task.Result as T
|
||||
//var task = this.ResultsTask;
|
||||
return (this.Result != null)
|
||||
? this.Result as T
|
||||
: null;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user