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:
Karl Burtram
2016-10-08 00:06:35 +00:00
committed by GitHub
parent 03d7fd94c8
commit f32b0290bb
5 changed files with 73 additions and 85 deletions

View File

@@ -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;
}
}