diff --git a/Apewer/Internals/Locker.cs b/Apewer/Internals/Locker.cs
index c38bdc5..d44f34b 100644
--- a/Apewer/Internals/Locker.cs
+++ b/Apewer/Internals/Locker.cs
@@ -1,18 +1,36 @@
using System;
using System.Collections.Generic;
-using System.Text;
+using static System.Collections.Specialized.BitVector32;
namespace Apewer.Internals
{
+ /// 整数锁。
+ internal sealed class Int32Locker : Locker
+ {
+
+ /// 获取整数的哈希值。
+ protected override int GetHash(int target) => target;
+
+ }
+
+ /// 文本锁。
+ internal sealed class TextLocker : Locker
+ {
+
+ /// 获取文本的哈希值。
+ protected override int GetHash(string target) => target == null ? 0 : target.GetHashCode();
+
+ }
+
/// 锁。
- internal class Locker
+ internal abstract class Locker
{
Dictionary> _pool = new Dictionary>();
- /// 标记指定的字符串。
- static int Key(string s) => s == null ? 0 : s.GetHashCode();
+ /// 获取目标的哈希值。
+ protected abstract int GetHash(TTarget key);
/// 清除所有缓存的锁。
public void Clear()
@@ -23,50 +41,40 @@ namespace Apewer.Internals
}
}
- /// 锁定字符串,执行 Action。
- public void InLock(string text, Action action)
+ Class