public void Update(string key, CacheBlock block) { lock (Locker) { CachePool.Update(key, block); } }
public void Clear() { lock (Locker) { CachePool.Clear(); } }
public static void PlayAudioOneShot(AudioSource audioSource, int soundId, float volume = 1f) { if (_globalAudioVolume <= 0 || _audioVolume <= 0) { return; } SoundDeploy deploy = _soundTableT.GetSection(soundId); if (!deploy || string.IsNullOrEmpty(deploy.resource)) { return; } AudioClip resource; if (CachePool.TryGetValue(deploy.resource, out resource)) { PlayAudioOneShot(audioSource, resource, volume, deploy.volume); } else { RLoadPlayAudioOneShot(deploy.resource, audioSource, volume, deploy.volume); } }
private static void RLoadPlayAudioOneShot(string soundName, AudioSource audioSource, float volume = 1f, float gvolume = 1f) { AudioClip resource; ResourceMgr.Load(soundName, _object => { resource = _object as AudioClip; if (resource != null) { if (!CachePool.ContainsKey(soundName)) { CachePool.Add(soundName, resource); } if (audioSource != null) { PlayAudioOneShot(audioSource, resource, volume, gvolume); } } else { Debug.LogError(string.Format("The AudioClip[resource={0}] is null.", resource)); } }); }
public void RemoveAll(Predicate <CacheBlock> pre) { lock (Locker) { CachePool.RemoveAll(pre); } }
public CacheBlock GetCache(string key) { lock (Locker) { return(CachePool.Get(key)); } }
#pragma warning disable CS1591 // 缺少对公共可见类型或成员的 XML 注释 protected override void Awake() { ThreadCache = new CachePool <InnerThread>(new RunningPool <InnerThread>(), new Threads()); semaphore = new Semaphore(maxThreads, ThreadCount); CacheArgs = new Queue <ThreadArgs>(); RunningArgs = new Queue <ThreadArgs>(); }
public void RemoveInternal <_T0>(IntrusiveCollection <_T0> list) where _T0 : IntrusiveCollection.Element { // IntrusiveCollection.Element System.Diagnostics.Debug.Assert(list == pool.GetDirectiveList()); this.pool = null; this.prev = null; this.next = null; }
public static void UnloadSoundAsset(AudioSource audioSource, int soundId) { if (audioSource != null) { SoundDeploy deploy = _soundTableT.GetSection(soundId); CachePool.Remove(deploy.resource); Resources.UnloadAsset(audioSource.clip); } }
public static void FadeOutMusic(float fade = 1f) { if (_music != null && _music.AudioSource != null) { CachePool.Remove(_music.Resources); Resources.UnloadAsset(_music.AudioSource.clip); Object.Destroy(_music.AudioSource.gameObject); } }
public override void Remove(CacheItem item, string key, bool isMainSlbServer = true) { var cacheKey = GenerateCacheKey(item, key); if (CachePool.Contains(cacheKey)) { CachePool.Remove(cacheKey); } }
public void DrawConnectLine(RuntimePort A, RuntimePort B) { CachePool.I().GetObject("Prefabs/Line", (obj) => { obj.transform.SetParent(RuntimeGraph.I().LineGroup, false); RuntimeLine line = obj.GetComponent <RuntimeLine>(); line.Draw(A, B); }); }
public static void StopEnvironmentMusic(float fade = 3f) { if (_environment != null && _environment.AudioSource != null) { CachePool.Remove(_environment.Resources); Resources.UnloadAsset(_environment.AudioSource.clip); Object.Destroy(_environment.AudioSource.gameObject); } }
public override void ClearAll() { lock (Padlock) { foreach (var cacheItem in CachePool) { CachePool.Remove(cacheItem.Key); } } }
/// <summary> /// Get a snaphot from the pool for a particular cache. /// </summary> public void DiposeSnapshot(string pointerID, CacheBase cache) { CachePool pool = null; if (_cachePoolMap.Contains(cache.Context.CacheRoot.Name)) { pool = _cachePoolMap[cache.Context.CacheRoot.Name] as CachePool; pool.DiposeSnapshotInPool(pointerID); } }
public static void StopMusic() { if (_music != null && _music.AudioSource != null) { CachePool.Remove(_music.Resources); Resources.UnloadAsset(_music.AudioSource.clip); Object.Destroy(_music.AudioSource.gameObject); _music.AudioSource = null; } }
public override object Get(CacheItem item, string key, MethodInfo methodInfo) { var cacheKey = GenerateCacheKey(item, key); if (CachePool.Contains(cacheKey)) { return((object)CachePool[cacheKey]); } return(null); }
// // IntrusiveCollection.Element implementation // public void InsertInternal <_T0>(IntrusiveCollection <_T0> list, IntrusiveCollection.Element prev, IntrusiveCollection.Element next) where _T0 : IntrusiveCollection.Element { // IntrusiveCollection.Element System.Diagnostics.Debug.Assert(this.pool == null); this.pool = ((CachePool.DirectiveList)list).GetCachePool(); this.prev = prev; this.next = next; }
public override void ClearItem(CacheItem item, bool isMainSlbServer = true) { lock (Padlock) { foreach (var cacheItem in CachePool.Where(p => p.Key.StartsWith(item.ToString()))) { CachePool.Remove(cacheItem.Key); } } }
public void GetInputer(string Type, string Name, object Value) { CachePool.I().GetObject("Prefabs/Content/" + Type, (obj) => { obj.transform.SetParent(ContentParent, false); Inputer inputer = obj.GetComponent <Inputer>(); inputer.SetLabel(Name); inputer.SetValue(Value); BaseInputer.Add(Name, inputer); }); }
void NextMenu(MenuItem item) { for (int i = 0; i < transform.childCount; i++) { //TODO: Change to put object if (transform.GetChild(i).name != "Label") { Destroy(transform.GetChild(i).gameObject); } } if (item.father != null) { CachePool.I().GetObject("Prefabs/Context/BackButton", (obj) => { obj.transform.SetParent(transform, false); RightClickMenuItem rcItem = obj.GetComponent <RightClickMenuItem>(); MenuItem next = item; rcItem.AddAction(() => { Label.text = Label.text.Substring(0, Label.text.Length - new StringBuilder("/").Append(item.name).ToString().Length); NextMenu(next.father); }); }); } for (int i = 0; i < item.SubItems.Count; i++) { CachePool.I().GetObject("Prefabs/Context/ContextButton", (obj) => { obj.transform.SetParent(transform, false); RightClickMenuItem rcItem = obj.GetComponent <RightClickMenuItem>(); rcItem.SetLabel(Item.SubItems[i].name); MenuItem nextItem = Item.SubItems[i]; MenuItem cur = item; rcItem.AddAction(() => { nextItem.father = cur; Label.text += new StringBuilder("/").Append(nextItem.name).ToString(); NextMenu(nextItem); }); }); } foreach (var key in item.ActualItem.Keys) { CachePool.I().GetObject("Prefabs/Context/ActualButton", (obj) => { obj.transform.SetParent(transform, false); RightClickMenuItem rcItem = obj.GetComponent <RightClickMenuItem>(); rcItem.SetLabel(key); rcItem.AddAction(item.ActualItem[key]); }); } }
private static void LoadPlayAudio(string soundName, AudioSource audioSource, float volume, bool loop, Action playCallBack) { AudioClip resource; if (CachePool.TryGetValue(soundName, out resource)) { DoPlayAudio(audioSource, resource, volume, loop, playCallBack); } else { RLoadPlayAudio(soundName, audioSource, volume, loop, playCallBack); } }
static ThreadPool() { ThreadCache = new CachePool <IFThread>(new RunningPool <IFThread>(), new IFThreads()); ArgCache = new CachePool <IFThreadArg>(new RunningPool <IFThreadArg>(), new IFThreadArgPool()); eve = new ManualResetEvent(false); CacheArgs = new Queue <IFThreadArg>(); RunningArgs = new Queue <IFThreadArg>(); ctrolThread = new Thread(ThreadLoop); ctrolThread.IsBackground = true; ctrolThread.Start(); }
public static void ClearSoundCache() { if (!GameSetting.CacheSound) { var e = CachePool.GetEnumerator(); using (e) { while (e.MoveNext()) { Resources.UnloadAsset(e.Current.Value); } } CachePool.Clear(); } }
/// <summary> /// Get a snaphot from the pool /// </summary> /// <param name="pointerID"></param> /// <param name="cache"></param> /// <returns></returns> public Array GetSnaphot(string pointerID, CacheBase cache) { CachePool pool = null; if (_cachePoolMap.Contains(cache.Context.CacheRoot.Name)) { pool = _cachePoolMap[cache.Context.CacheRoot.Name] as CachePool; return(pool.GetSnaphotInPool(pointerID, cache)); } else { pool = new CachePool(_minSnaphotSizeForPooling, _maxSnapshotsInPool, _newSnapshotCreationThreshold); _cachePoolMap.Add(cache.Context.CacheRoot.Name, pool); } return(pool.GetSnaphotInPool(pointerID, cache)); }
/// <summary> /// Get a snaphot from the pool /// </summary> /// <param name="pointerID"></param> /// <param name="cache"></param> /// <returns></returns> public Array GetSnaphot(string pointerID, CacheBase cache) { CachePool pool = null; if (_cachePoolMap.Contains(cache.Context.CacheRoot.Name)) { pool = _cachePoolMap[cache.Context.CacheRoot.Name] as CachePool; return(pool.GetSnaphotInPool(pointerID, cache)); } else { pool = new CachePool(); _cachePoolMap.Add(cache.Context.CacheRoot.Name, pool); } return(pool.GetSnaphotInPool(pointerID, cache)); }
public override void Set(CacheItem item, string key, object data, int second = 0) { if (data == null) { return; } var cacheKey = GenerateCacheKey(item, key); if (CachePool.Contains(cacheKey)) { CachePool[cacheKey] = data; } else { CachePool.Add(cacheKey, data, GetPolicy(second)); } }
private static void RLoadPlayAudio(string soundName, AudioSource audioSource, float volume, bool loop, Action playCallBack) { AudioClip resource; ResourceMgr.Load(soundName, _object => { resource = _object as AudioClip; if (resource) { if (!CachePool.ContainsKey(soundName)) { CachePool.Add(soundName, resource); } DoPlayAudio(audioSource, resource, volume, loop, playCallBack); } else { Debug.LogError("加载声音失败:" + soundName); } }); }
IEnumerator IE_Load() { //Load All Nodes for (int i = 0; i < graph.Node.Count; i++) { CachePool.I().GetObject("Prefabs/NodeBase", (obj) => { obj.transform.SetParent(NodeGroup, false); RuntimeNode rnode = obj.GetComponent <RuntimeNode>(); rnode.Load(graph.Node[i]); Nodes.Add(rnode); }); } //Connect All Ports for (int i = 0; i < Nodes.Count; i++) { Nodes[i].Connect(); } yield return(null); Save(); }
public RollObj() { list = new ArrayList(); size = new S(); pool = new CachePool <GameObject, Args, T>(); }
/// <summary> /// Get a snaphot from the pool /// </summary> /// <param name="pointerID"></param> /// <param name="cache"></param> /// <returns></returns> public Array GetSnaphot(string pointerID, CacheBase cache) { CachePool pool = null; if (_cachePoolMap.Contains(cache.Context.CacheRoot.Name)) { pool = _cachePoolMap[cache.Context.CacheRoot.Name] as CachePool; return pool.GetSnaphotInPool(pointerID, cache); } else { pool = new CachePool(_minSnaphotSizeForPooling, _maxSnapshotsInPool, _newSnapshotCreationThreshold); _cachePoolMap.Add(cache.Context.CacheRoot.Name, pool); } return pool.GetSnaphotInPool(pointerID, cache); }