public Task <List <ComponentWithId> > GetBatch(string collectionName, List <long> idList) { List <ComponentWithId> components = new List <ComponentWithId>(); bool isAllInCache = true; foreach (long id in idList) { ComponentWithId component = this.GetFromCache(collectionName, id); if (component == null) { isAllInCache = false; break; } components.Add(component); } if (isAllInCache) { return(Task.FromResult(components)); } TaskCompletionSource <List <ComponentWithId> > tcs = new TaskCompletionSource <List <ComponentWithId> >(); DBQueryBatchTask dbQueryBatchTask = ComponentFactory.Create <DBQueryBatchTask, List <long>, string, TaskCompletionSource <List <ComponentWithId> > >(idList, collectionName, tcs); this.tasks[(int)((ulong)dbQueryBatchTask.Id % taskCount)].Add(dbQueryBatchTask); return(tcs.Task); }
public ETTask <List <ComponentWithId> > GetBatch(string collectionName, List <long> idList) { ETTaskCompletionSource <List <ComponentWithId> > tcs = new ETTaskCompletionSource <List <ComponentWithId> >(); DBQueryBatchTask dbQueryBatchTask = ComponentFactory.Create <DBQueryBatchTask, List <long>, string, ETTaskCompletionSource <List <ComponentWithId> > >(idList, collectionName, tcs); this.tasks[(int)((ulong)dbQueryBatchTask.Id % taskCount)].Add(dbQueryBatchTask); return(tcs.Task); }
public override void Awake(DBQueryBatchTask self, List <long> idList, string collectionName, ETTaskCompletionSource <List <ComponentWithId> > tcs) { self.IdList = idList; self.CollectionName = collectionName; self.Tcs = tcs; }