Exemplo n.º 1
0
 public static void RegisterReceive(string listUser, string listName)
 {
     System.Diagnostics.Debug.WriteLine("** LIST LISTEN START:@" + listUser + "/" + listName);
     listName = NormalizeListName(listName);
     var fullname = BuildListName(listUser, listName);
     lock (rcLocker)
     {
         if (referenceCount.ContainsKey(fullname))
         {
             referenceCount[fullname]++;
         }
         else
         {
             var target = AccountStorage.Get(listUser);
             if (target == null)
                 target = AccountStorage.GetRandom(ai => ai.IsFollowingList(listUser, listName), true);
             var tscheduler = target != null ? AutoCruiseSchedulerManager.GetScheduler(target) : null;
             if (tscheduler == null)
             {
                 // スケジューラがまだない
                 // スケジューラが更新されるまで待つ
                 waitings.Add(new Tuple<string, string>(listUser, listName));
                 return;
             }
             var task = new ListReceiveTask(target, listUser, listName);
             receivers.Add(fullname, task);
             tscheduler.AddSchedule(task);
             Task.Factory.StartNew(() => ListStorage.Get(listUser, listName));
             referenceCount.Add(fullname, 1);
         }
     }
 }
Exemplo n.º 2
0
        public static void RegisterReceive(string listUser, string listName)
        {
            System.Diagnostics.Debug.WriteLine("** LIST LISTEN START:@" + listUser + "/" + listName);
            listName = NormalizeListName(listName);
            var fullname = BuildListName(listUser, listName);

            lock (rcLocker)
            {
                if (referenceCount.ContainsKey(fullname))
                {
                    referenceCount[fullname]++;
                }
                else
                {
                    var target = AccountStorage.Get(listUser);
                    if (target == null)
                    {
                        target = AccountStorage.GetRandom(ai => ai.IsFollowingList(listUser, listName), true);
                    }
                    var tscheduler = target != null?AutoCruiseSchedulerManager.GetScheduler(target) : null;

                    if (tscheduler == null)
                    {
                        // スケジューラがまだない
                        // スケジューラが更新されるまで待つ
                        waitings.Add(new Tuple <string, string>(listUser, listName));
                        return;
                    }
                    var task = new ListReceiveTask(target, listUser, listName);
                    receivers.Add(fullname, task);
                    tscheduler.AddSchedule(task);
                    Task.Factory.StartNew(() => ListStorage.Get(listUser, listName));
                    referenceCount.Add(fullname, 1);
                }
            }
        }