Beispiel #1
0
        public void EnqueueDeferred(IEntity source, QueueAction a)
        {
            if (a == null)
            {
                return;
            }
#if _QUEUE_DEBUG
            DebugLog.WriteLine("Queue (Game " + Game.GameId + "): Queueing action " + a + " for " + source.ShortDescription + " at depth " + Depth);
#endif
            var e = initializeAction(source, a);
            if (OnQueueing != null)
            {
                OnQueueing(this, e);
                // TODO: Count the number of arguments the cancelled action would take and remove those too
                if (!e.Cancel)
                {
                    Queue.AddBack(e);
                }
            }
            else
            {
                Queue.AddBack(e);
            }
            OnQueued?.Invoke(this, e);
        }
Beispiel #2
0
 public void Add(string steamId, QueueAction action)
 {
     lock (_lock)
     {
         _dictionary.Add(steamId, action);
     }
 }
Beispiel #3
0
        void OnImportClicked()
        {
            _queue = new QueueAction();
            if (!AssetDatabase.IsValidFolder(_folderPath + "/Resources"))
            {
                AssetDatabase.CreateFolder(_folderPath, "Resources");
            }

            if (!AssetDatabase.IsValidFolder(_folderPath + "/Scripts"))
            {
                AssetDatabase.CreateFolder(_folderPath, "Scripts");
            }

            EditorUtility.ClearProgressBar();

            foreach (var ggSheet in _sheetSetting.GoogleSheets)
            {
                foreach (var sheet in ggSheet.sheetNames)
                {
                    var sheetName = sheet.name;
                    var startCell = sheet.startCell;
                    var endCell   = sheet.endCell;
                    var buildText = sheet.buildText;

                    _queue.AddQueue(new Action <string, string, string, string, bool>(ExportSheet), new object[] { ggSheet.spreadSheetKey, sheetName, startCell, endCell, buildText });
                }
            }

            _queue.NextAction(true);
        }
        void IServer.HandleUserEnterQueue(IServerUser user, QueueAction action)
        {
            var matchmaking = GetMatchmaking(user, action);

            if (matchmaking == null)
            {
                return;
            }

            lock (matchmaking)
            {
                var regCount = matchmaking.GetRegisterCount(user);
                if (regCount >= _config.MaxQueueCount)
                {
                    user.IllegalAction("Exceeded max queue action: " + _config.MaxQueueCount);
                    return;
                }

                var queueLimitExclusive = Math.Min(_config.MaxQueueCount, regCount + action.Count);
                for (; regCount < queueLimitExclusive; regCount++)
                {
                    matchmaking.EnterQueue(user);
                }

                user.Send(Packet.PacketTypeS2C.QueueState, regCount);
            }
        }
Beispiel #5
0
        public QueueItem Enqueue(QueueItemType type, QueueAction action)
        {
            var item = new QueueItem(type, action);

            Enqueue(item);
            return(item);
        }
        void IServer.HandleUserLeaveQueue(IServerUser user, QueueAction action)
        {
            var matchmaking = GetMatchmaking(user, action);

            if (matchmaking == null)
            {
                return;
            }

            lock (matchmaking)
            {
                var regCount = matchmaking.GetRegisterCount(user);
                if (action.Count >= regCount)
                {
                    matchmaking.LeaveQueueCompletely(user);
                }
                else
                {
                    for (var i = 0; i < action.Count; i++)
                    {
                        matchmaking.LeaveQueue(user);
                    }
                }

                user.Send(Packet.PacketTypeS2C.QueueState, Math.Max(0, regCount - action.Count));
            }
        }
Beispiel #7
0
    public static QueueAction Create(int max_)
    {
        QueueAction queue = new QueueAction();

        queue.Start(max_);
        return(queue);
    }
Beispiel #8
0
 private void OnEnable()
 {
     if (_queue == null)
     {
         _queue = new QueueAction();
     }
 }
Beispiel #9
0
 public ActionGraph(QueueAction q)
 {
     Graph = new List <QueueAction>()
     {
         q
     };
 }
Beispiel #10
0
		public QueueActionEventArgs(Game g, IEntity s, QueueAction a, ActionResult[] p = null, object u = null) {
			Game = g;
			Source = s;
			Action = a;
			Args = p;
			UserData = u;
			Cancel = false;
		}
Beispiel #11
0
 public void StartBlock(IEntity source, QueueAction a, BlockStart gameBlock = null)
 {
     if (a != null)
     {
         StartBlock(source, new List <QueueAction> {
             a
         }, gameBlock);
     }
 }
        public void ProcessorValue()
        {
            var expected = new QueueActivity <object>(async(obj) => { return(await Task.FromResult <bool>(true)); });
            var qc       = new QueueAction <object>()
            {
                Activity = expected,
            };

            Assert.IsNotNull(qc.Processor() as ActionProcessor <object>);
        }
        public void Activity()
        {
            var expected = new QueueActivity <object>(async(obj) => { return(await Task.FromResult <bool>(true)); });
            var qc       = new QueueAction <object>()
            {
                Activity = expected,
            };

            Assert.AreEqual(expected, qc.Activity);
        }
Beispiel #14
0
        public Queue(ISenderAgent senderAgent, IQueueEvents queueEvents, IMetaDataBusiness metaDataBusiness, IQueueSettings queueSettings)
        {
            _pointValidator = new PointValidator();
            queueEvents.OnDebugMessageEvent($"Preparing new queue with target {senderAgent.TargetDescription}.");
            _queueAction = new QueueAction(queueEvents, GetQueueInfo);

            _senderAgent      = senderAgent;
            _queueEvents      = queueEvents;
            _metaDataBusiness = metaDataBusiness;
            _queueSettings    = queueSettings;
        }
Beispiel #15
0
    void Move(QueueAction from, QueueAction to)
    {
        platform.MonitorEnter(mainThreadActionsLock);
        int count = from.count;

        for (int i = 0; i < count; i++)
        {
            Action_ task = from.Dequeue();
            to.Enqueue(task);
        }
        platform.MonitorExit(mainThreadActionsLock);
    }
Beispiel #16
0
        public void Init()
        {
            config = (GoogleSheetsToUnityConfig)Resources.Load(_gstuAPIsConfig);
            var finds = AssetDatabase.FindAssets($"t:{_sheetSettingAsset}", null);

            foreach (var item in finds)
            {
                var path = AssetDatabase.GUIDToAssetPath(item);
                _sheetSetting = AssetDatabase.LoadAssetAtPath <SheetSetting>(path);
            }

            if (_queue == null)
            {
                _queue = new QueueAction();
            }
        }
        private IMatchmaking GetMatchmaking(IServerUser user, QueueAction action)
        {
            if (action.Count <= 0)
            {
                user.IllegalAction("Invalid queue count");
                return(null);
            }

            IMatchmaking matchmaking;

            if (!_matchmaking.TryGetValue(action.GameMode, out matchmaking))
            {
                user.IllegalAction("There is no such gamemode");
                return(null);
            }
            return(matchmaking);
        }
Beispiel #18
0
    public ServerSimple()
    {
        one             = 1;
        clients         = new ClientSimple[256];
        clientsCount    = 0;
        blockTypes      = new Packet_BlockType[GlobalVar.MAX_BLOCKTYPES];
        blockTypesCount = 0;
        mods            = new ModSimple[128];

        ModManagerSimple1 m = new ModManagerSimple1();

        m.Start(this);

        mods[modsCount++] = new ModSimpleDefault();
        mods[modsCount++] = new ModSimpleWorldGenerator();
        for (int i = 0; i < modsCount; i++)
        {
            mods[i].Start(m);
        }

        MapSizeX          = 8192;
        MapSizeY          = 8192;
        MapSizeZ          = 128;
        chunks            = new ChunkSimple[(MapSizeX / ChunkSize) * (MapSizeY / ChunkSize)][];
        chunkdrawdistance = 4;
        actions           = new QueueAction();
        mainThreadActions = new QueueAction();

        spawnGlX = MapSizeX / 2;
        spawnGlY = MapSizeZ;
        for (int i = 0; i < modsCount; i++)
        {
            int spawnHeight = mods[i].GetHeight();
            if (spawnHeight != -1)
            {
                spawnGlY = spawnHeight;
            }
        }
        spawnGlZ = MapSizeY / 2;
    }
    public ServerSimple()
    {
        one = 1;
        clients = new ClientSimple[256];
        clientsCount = 0;
        blockTypes = new Packet_BlockType[GlobalVar.MAX_BLOCKTYPES];
        blockTypesCount = 0;
        mods = new ModSimple[128];

        ModManagerSimple1 m = new ModManagerSimple1();
        m.Start(this);

        mods[modsCount++] = new ModSimpleDefault();
        mods[modsCount++] = new ModSimpleWorldGenerator();
        for (int i = 0; i < modsCount; i++)
        {
            mods[i].Start(m);
        }

        MapSizeX = 8192;
        MapSizeY = 8192;
        MapSizeZ = 128;
        chunks = new ChunkSimple[(MapSizeX / ChunkSize) * (MapSizeY / ChunkSize)][];
        chunkdrawdistance = 4;
        actions = new QueueAction();
        mainThreadActions = new QueueAction();

        spawnGlX = MapSizeX / 2;
        spawnGlY = MapSizeZ;
        for (int i = 0; i < modsCount; i++)
        {
            int spawnHeight = mods[i].GetHeight();
            if (spawnHeight != -1)
            {
                spawnGlY = spawnHeight;
            }
        }
        spawnGlZ = MapSizeY / 2;
    }
Beispiel #20
0
 public void Queue(IEntity source, QueueAction a)
 {
     ActionQueue.EnqueueDeferred(source, a);
 }
Beispiel #21
0
 public ActionResult Action(IEntity source, QueueAction a)
 {
     return(ActionQueue.Run(source, a));
 }
Beispiel #22
0
 public Task <ActionResult> ActionAsync(IEntity source, QueueAction a)
 {
     return(ActionQueue.RunAsync(source, a));
 }
Beispiel #23
0
 // Gets a QueueAction that can put into the queue
 private QueueActionEventArgs initializeAction(IEntity source, QueueAction qa)
 {
     return(new QueueActionEventArgs(Game, source, qa));
 }
Beispiel #24
0
 /// <summary>
 /// Enqueues the specified dependent to only execute after the specified dependency has finished.  If this
 /// dependency has already finished, then it will simply be enqueued on the main processor.
 /// </summary>
 public QueueItem EnqueueDependent(QueueItem dependency, QueueItemType type, QueueAction action)
 {
     return(EnqueueDependent(new[] { dependency }, type, action));
 }
 public Queue(MonoBehaviour context, QueueAction queueAction, int maxConcurrentRequests = 1)
 {
     this.context               = context;
     this.queueAction           = queueAction;
     this.maxConcurrentRequests = maxConcurrentRequests;
 }
 void Move(QueueAction from, QueueAction to)
 {
     platform.MonitorEnter(mainThreadActionsLock);
     int count = from.count;
     for (int i = 0; i < count; i++)
     {
         Action_ task = from.Dequeue();
         to.Enqueue(task);
     }
     platform.MonitorExit(mainThreadActionsLock);
 }
Beispiel #27
0
 public Task <ActionResult> RunAsync(IEntity source, QueueAction a)
 {
     return(a != null?RunAsync(source, new List <QueueAction> {
         a
     }) : Task.FromResult(ActionResult.None));
 }
Beispiel #28
0
 public ActionResult Run(IEntity source, QueueAction a)
 {
     return(RunAsync(source, a).Result);
 }
 public static QueueAction Create(int max_)
 {
     QueueAction queue = new QueueAction();
     queue.Start(max_);
     return queue;
 }
Beispiel #30
0
        public QueueItem(QueueItemType type, QueueAction action)
        {
            this.action = action;

            Type = type;
        }
 //==============================================================================================
 /// <summary>
 /// Synchronizes access to the bulk in completed buffers queue
 /// </summary>
 /// <param name="bulkInBuffer">The buffer to queue</param>
 /// <param name="queueAction">The actions to take (enqueue or dequeue)</param>
 /// <returns>The buffer that was dequeued</returns>
 //==============================================================================================
 internal BulkInBuffer QueueBulkInCompletedBuffers(BulkInBuffer bulkInBuffer, QueueAction queueAction)
 {
     lock (m_bulkInCompletedBuffersLock)
     {
         try
         {
             if (queueAction == QueueAction.Enqueue)
             {
                 m_bulkInCompletedBuffers.Enqueue(bulkInBuffer);
                 return null;
             }
             else
             {
                 if (m_bulkInCompletedBuffers.Count > 0)
                 {
                     return m_bulkInCompletedBuffers.Dequeue();
                 }
                 else
                 {
                     return null;
                 }
             }
         }
         catch (Exception ex)
         {
             System.Diagnostics.Debug.Assert(false, ex.Message);
             return null;
         }
     }
 }
Beispiel #32
0
        /// <summary>
        /// EncodeQueue
        /// </summary>
        /// <param name="JsonStr"></param>
        /// <param name="action"></param>
        /// <param name="recipient_name"></param>
        /// <returns></returns>
        public static string EncodingQueueMessage(dynamic Queue, string lanecode, string lanename, QueueAction action, string recipient_name = "ALL")
        {
            #region 废弃
            ////母版
            //dynamic result = JsonConvert.DeserializeObject<dynamic>(File.ReadAllText(Application.StartupPath + "/conf/queue.json"));
            ////赋值
            //dynamic BeEncodeObj = Queue;
            ////解析
            //Queue.message_content.
            //result.message_type = "queue";
            //result.sender_code = lanecode;
            //result.sender_name = lanename;
            //result.message_content.lane_code = lanecode;
            //BeEncodeObj.lane_code = lanecode;
            //BeEncodeObj.lane_name = lanename;
            //result.recipient_code = recipient_name;
            //result.recipient_name = recipient_name;
            //result.send_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
            //switch (action)
            //{
            //    case QueueAction.create:
            //        result.message_content.queue_code = new Guid();
            //        BeEncodeObj.quque_code = result.message_content.queue_code;
            //        result.message_content.action = "create";
            //        break;
            //    case QueueAction.update:
            //        result.message_content.action = "update";
            //        break;
            //    case QueueAction.delete:
            //        result.message_content.action = "delete";
            //        break;
            //}

            //BeEncodeObj.update_time = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff");
            //result.message_content.queue = BeEncodeObj;
            //return JsonConvert.SerializeObject(result);
            #endregion
            Queue.sender_code                     = lanecode;
            Queue.sender_name                     = lanename;
            Queue.recipient_code                  = recipient_name;
            Queue.recipient_name                  = recipient_name;
            Queue.send_time                       = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss.fff");
            Queue.message_content.lane_code       = lanecode;
            Queue.message_content.create_time     = DateTime.Now.ToString("yyyy - MM - dd HH: mm:ss.fff");
            Queue.message_content.queue.lane_code = lanecode;
            switch (action)
            {
            case QueueAction.create:
                var d = Guid.NewGuid().ToString();
                Queue.message_content.queue_code       = d;
                Queue.message_content.queue.queue_code = d;
                Queue.message_content.action           = "create";
                break;

            case QueueAction.update:
                Queue.message_content.action = "update";
                break;

            case QueueAction.delete:
                Queue.message_content.action = "delete";
                break;
            }
            Queue.message_content.queue.snapshot_time = DateTime.Now.ToString();
            Queue.message_content.queue.update_time   = DateTime.Now.ToString();

            return(JsonConvert.SerializeObject(Queue));
        }
 //================================================================================================
 /// <summary>
 /// Enqueues and dequeues bulk in buffers. Separate threads enqueue and dequeue bulk in buffers
 /// so they are synchronized here
 /// </summary>
 /// <param name="bulkInBuffer">The bulk in buffer to enqueue</param>
 /// <param name="queueAction">The queue action - Enqueue or Dequeue</param>
 /// <returns>The bulk in buffer that was dequeued</returns>
 //================================================================================================
 protected byte[] QueueBuffer(byte[] bulkInBuffer, QueueAction queueAction)
 {
     lock (queueBufferLock)
     {
         if (queueAction == QueueAction.Enqueue)
         {
             m_completedBulkInRequestBuffers.Enqueue(bulkInBuffer);
             return null;
         }
         else
         {
             return m_completedBulkInRequestBuffers.Dequeue();
         }
     }
 }
Beispiel #34
0
 //=============================================================================================================================================
 /// <summary>
 /// Enqueues and dequeues the callback info for the OnDataAvailable callback
 /// </summary>
 /// <param name="avaiableSamplesPerChannel">The number of samples per channel available for the callback</param>
 /// <param name="samplesReadPerChannel">The number of samples per channel that has been read at the time the callback info was queued</param>
 /// <param name="queueAction">The queue action - Enqueue or Dequeue</param>
 /// <returns>The number of available samples that was dequeued</returns>
 //=============================================================================================================================================
 protected CallbackInfo QueueCallbackInfo(int avaiableSamplesPerChannel, ulong samplesReadPerChannel, QueueAction queueAction)
 {
     lock (callbackInfoQueueLock)
     {
         if (queueAction == QueueAction.Enqueue)
         {
             m_callbackInfoQueue.Enqueue(new CallbackInfo(avaiableSamplesPerChannel, samplesReadPerChannel));
             return null;
         }
         else
         {
             if (m_callbackInfoQueue.Count > 0)
                 return m_callbackInfoQueue.Dequeue();
             else
                 return null;
         }
     }
 }
 //==============================================================================================
 /// <summary>
 /// Synchronizes access to the bulk in ready buffers queue
 /// </summary>
 /// <param name="bulkInBuffer">The buffer to queue</param>
 /// <param name="queueAction">The actions to take (enqueue or dequeue)</param>
 /// <returns>The buffer that was dequeued</returns>
 //==============================================================================================
 internal BulkInBuffer QueueBulkInReadyBuffers(BulkInBuffer bulkInBuffer, QueueAction queueAction)
 {
     lock (m_bulkInReadyBuffersLock)
     {
         if (queueAction == QueueAction.Enqueue)
         {
             m_bulkInReadyBuffers.Enqueue(bulkInBuffer);
             return null;
         }
         else
         {
             if (m_bulkInReadyBuffers.Count > 0)
             {
                 return m_bulkInReadyBuffers.Dequeue();
             }
             else
             {
                 return null;
             }
         }
     }
 }
Beispiel #36
0
        /// <summary>
        /// Enqueues the specified dependent to only execute after the specified dependencies have finished.  If all the
        /// dependencies have already finished, then it will simply be enqueued on the main processor.
        /// </summary>
        public QueueItem EnqueueDependent(IEnumerable <QueueItem> dependencies, QueueItemType type, QueueAction action)
        {
            var dependent = new QueueItem(type, action);

            EnqueueDependent(dependencies, dependent);
            return(dependent);
        }