public IMessage PublishByNumber(Type type, IEventArgs args, int priority = MessageUrgency.Common) { var message = Framework.GlobalAllocate <Message>(); message.Begin(); message.SetArgs(args).SetType(type); if (priority < 0) { HandleMessage(message); } else { using (new LockWait(ref _lock_message)) { if (_priorityQueue.count == _priorityQueue.capcity) { _priorityQueue.Resize(_priorityQueue.capcity * 2); } StablePriorityQueueNode node = Framework.GlobalAllocate <StablePriorityQueueNode>(); _priorityQueue.Enqueue(node, priority); excuteMap.Add(node, message); _updatelist.Add(node); } } return(message); }
public IMessage PublishByNumber(Type type, IEventArgs args, int priority = MessageUrgency.Common) { var message = _pool.Get(); message.Begin(); message.SetArgs(args).SetType(type); if (priority < 0) { HandleMessage(message); } else { using (new LockWait(ref _lock_message)) { if (_queue.count == _queue.capcity) { _queue.Resize(_queue.capcity * 2); } var node = nodePool.Get(); _queue.Enqueue(node, priority); excuteMap.Add(node, message); _list.Add(node); } } return(message); }
public void Enqueue(T item, float priority) { SimpleNode node = new SimpleNode(item); if (queue.Count == queue.MaxSize) { queue.Resize(queue.MaxSize * 2 + 1); } queue.Enqueue(node, priority); }
/// <summary> /// 按批量方式进行资源的加载 /// 如果指定使用标签进行资源加载,则会忽略<paramref name="addresses"/>的值 /// </summary> /// <param name="label">加载设定指定标签的资源</param> /// <param name="addresses">资源加载地址</param> /// <param name="isInstance">是否需要实例化</param> /// <param name="complete">单个资源加载完毕后回调</param> /// <param name="batchComplete">所有资源加载完毕后回调</param> /// <param name="progress">单个资源加载进度回调</param> /// <param name="batchProgress">所有资源加载进度回调</param> /// <param name="priority">优先级</param> /// <param name="userData">自定义参数</param> /// <returns></returns> internal AssetHandler LoadBatchAssetAsync( string label, string[] addresses, bool isInstance, OnAssetLoadComplete complete, OnBatchAssetLoadComplete batchComplete, OnAssetLoadProgress progress, OnBatchAssetsLoadProgress batchProgress, AssetLoaderPriority priority, SystemObject userData) { //如果指定按标签加载资源,则查找标记为指定标签的所有资源 if (!string.IsNullOrEmpty(label)) { addresses = addressConfig.GetAddressesByLabel(label); DebugLog.Debug(AssetConst.LOGGER_NAME, $"AssetLoader::LoadBatchAssetAsync->Load asset by label.label = {label},addresses = {string.Join(",",addresses)}"); } if (addresses == null || addresses.Length == 0) { DebugLog.Error(AssetConst.LOGGER_NAME, "AAssetLoader::LoadBatchAssetAsync->addresses is null"); return(null); } //获取资源真实的路径 string[] paths = addressConfig.GetPathsByAddresses(addresses); if (paths == null || paths.Length == 0) { DebugLog.Error(AssetConst.LOGGER_NAME, "AssetLoader::LoadBatchAssetAsync->paths is null"); return(null); } else { DebugLog.Debug(AssetConst.LOGGER_NAME, $"AssetLoader::LoadBatchAssetAsync->find assetPath by address.addresses = {string.Join(",", addresses)},path = {string.Join(",",paths)}"); } if (dataWaitingQueue.Count >= dataWaitingQueue.MaxSize) { dataWaitingQueue.Resize(dataWaitingQueue.MaxSize * 2); DebugLog.Debug(AssetConst.LOGGER_NAME, "AssetLoader::LoadBatchAssetAsync->Reset the queue size."); } AssetLoaderData data = dataPool.Get(); data.InitData(label, addresses, paths, isInstance, complete, progress, batchComplete, batchProgress, userData); data.State = AssetLoaderDataState.Waiting; dataWaitingQueue.Enqueue(data, (float)priority); return(data.Handler); }