mirror of
https://github.com/greenshot/greenshot
synced 2025-07-16 10:03:44 -07:00
Merge remote-tracking branch 'remotes/origin/master' into release/1.2.9
This commit is contained in:
commit
0323705513
276 changed files with 5382 additions and 3666 deletions
|
@ -31,10 +31,10 @@ namespace GreenshotPlugin.Core {
|
|||
/// <typeparam name="TV">Type of value</typeparam>
|
||||
public class Cache<TK, TV> {
|
||||
private static readonly ILog LOG = LogManager.GetLogger(typeof(Cache<TK, TV>));
|
||||
private IDictionary<TK, TV> internalCache = new Dictionary<TK, TV>();
|
||||
private object lockObject = new object();
|
||||
private int secondsToExpire = 10;
|
||||
private CacheObjectExpired expiredCallback = null;
|
||||
private readonly IDictionary<TK, TV> internalCache = new Dictionary<TK, TV>();
|
||||
private readonly object lockObject = new object();
|
||||
private readonly int secondsToExpire = 10;
|
||||
private readonly CacheObjectExpired expiredCallback;
|
||||
public delegate void CacheObjectExpired(TK key, TV cacheValue);
|
||||
|
||||
/// <summary>
|
||||
|
@ -74,8 +74,11 @@ namespace GreenshotPlugin.Core {
|
|||
get {
|
||||
List<TV> elements = new List<TV>();
|
||||
|
||||
foreach (TV element in internalCache.Values) {
|
||||
elements.Add(element);
|
||||
lock (lockObject)
|
||||
{
|
||||
foreach (TV element in internalCache.Values) {
|
||||
elements.Add(element);
|
||||
}
|
||||
}
|
||||
foreach (TV element in elements) {
|
||||
yield return element;
|
||||
|
@ -105,8 +108,12 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
/// <param name="key"></param>
|
||||
/// <returns>true if the cache contains the key</returns>
|
||||
public bool Contains(TK key) {
|
||||
return internalCache.ContainsKey(key);
|
||||
public bool Contains(TK key)
|
||||
{
|
||||
lock (lockObject)
|
||||
{
|
||||
return internalCache.ContainsKey(key);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -168,7 +175,7 @@ namespace GreenshotPlugin.Core {
|
|||
/// </summary>
|
||||
private class CachedItem {
|
||||
public event CacheObjectExpired Expired;
|
||||
private int secondsToExpire;
|
||||
private readonly int secondsToExpire;
|
||||
private readonly Timer _timerEvent;
|
||||
|
||||
public CachedItem(TK key, TV item, int secondsToExpire) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue