public List <ExtendedGroupNoticeData> GetGroupNotices(UUID GroupID, NoticeListDelegate d) { object notices = null; bool firstCall = false; string cacheKey = "notices-" + GroupID.ToString(); //m_log.DebugFormat("[XXX]: GetGroupNotices {0}", cacheKey); while (true) { lock (m_Cache) { if (m_Cache.TryGetValue(cacheKey, out notices)) { //m_log.DebugFormat("[XXX]: GetGroupNotices {0} cached!", cacheKey); return((List <ExtendedGroupNoticeData>)notices); } // not cached if (!m_ActiveRequests.ContainsKey(cacheKey)) { m_ActiveRequests.Add(cacheKey, true); firstCall = true; } } if (firstCall) { try { notices = d(); lock (m_Cache) { m_Cache.AddOrUpdate(cacheKey, notices, GROUPS_CACHE_TIMEOUT); return((List <ExtendedGroupNoticeData>)notices); } } finally { lock (m_Cache) { m_ActiveRequests.Remove(cacheKey); } } } else { Thread.Sleep(50); } } }
public List<ExtendedGroupNoticeData> GetGroupNotices(UUID GroupID, NoticeListDelegate d) { object notices = null; bool firstCall = false; string cacheKey = "notices-" + GroupID.ToString(); //m_log.DebugFormat("[XXX]: GetGroupNotices {0}", cacheKey); while (true) { lock (m_Cache) { if (m_Cache.TryGetValue(cacheKey, out notices)) { //m_log.DebugFormat("[XXX]: GetGroupNotices {0} cached!", cacheKey); return (List<ExtendedGroupNoticeData>)notices; } // not cached if (!m_ActiveRequests.ContainsKey(cacheKey)) { m_ActiveRequests.Add(cacheKey, true); firstCall = true; } } if (firstCall) { try { notices = d(); lock (m_Cache) { m_Cache.AddOrUpdate(cacheKey, notices, GROUPS_CACHE_TIMEOUT); return (List<ExtendedGroupNoticeData>)notices; } } finally { m_ActiveRequests.Remove(cacheKey); } } else Thread.Sleep(50); } }