|
|
@ -31,6 +31,11 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton |
|
|
|
/// </summary>
|
|
|
|
private ReaderWriterLockSlim MsDictRWLock { get; } = new(); |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// MarkSearcherDict 中 MarkLabel 原子操作锁
|
|
|
|
/// </summary>
|
|
|
|
private ReaderWriterLockSlim MsMlRWLock { get; } = new(); |
|
|
|
|
|
|
|
#endregion Attr
|
|
|
|
|
|
|
|
public MarkSearcherServer( |
|
|
@ -51,7 +56,7 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
MsDictRWLock.EnterWriteLock(); |
|
|
|
MsDictRWLock.TryEnterWriteLock(2000); |
|
|
|
return ActivateSearcherAtom(cameraId); |
|
|
|
} |
|
|
|
finally |
|
|
@ -126,7 +131,7 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
MsDictRWLock.EnterWriteLock(); |
|
|
|
MsDictRWLock.TryEnterWriteLock(2000); |
|
|
|
return DeactivateSearcherAtom(cameraId); |
|
|
|
} |
|
|
|
finally |
|
|
@ -170,6 +175,25 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton |
|
|
|
} |
|
|
|
|
|
|
|
public bool ActivateMarkLabel(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
MsMlRWLock.TryEnterWriteLock(2000); |
|
|
|
return ActivateMarkLabelAtom(cameraId, markLabelId); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
MsMlRWLock.ExitWriteLock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// ActivateMarkLabel 原子操作
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cameraId"></param>
|
|
|
|
/// <param name="markLabelId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private bool ActivateMarkLabelAtom(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
bool ret = MarkSearcherDict.TryGetValue(cameraId, out MarkSearcherBase markSearcher); |
|
|
|
if (!ret) return false; |
|
|
@ -190,6 +214,25 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton |
|
|
|
} |
|
|
|
|
|
|
|
public bool DeactivateMarkLabel(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
try |
|
|
|
{ |
|
|
|
MsMlRWLock.TryEnterWriteLock(2000); |
|
|
|
return DeactivateMarkLabelAtom(cameraId, markLabelId); |
|
|
|
} |
|
|
|
finally |
|
|
|
{ |
|
|
|
MsMlRWLock.ExitWriteLock(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
/// DeactivateMarkLabel 原子操作
|
|
|
|
/// </summary>
|
|
|
|
/// <param name="cameraId"></param>
|
|
|
|
/// <param name="markLabelId"></param>
|
|
|
|
/// <returns></returns>
|
|
|
|
private bool DeactivateMarkLabelAtom(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
bool ret = MarkSearcherDict.TryGetValue(cameraId, out MarkSearcherBase markSearcher); |
|
|
|
if (!ret) return false; |
|
|
@ -203,64 +246,54 @@ public class MarkSearcherServer : IMarkSearcherServer, ISingleton |
|
|
|
&& searcher.IsExistsMarkLabelCalcParams(markLabelId); |
|
|
|
} |
|
|
|
|
|
|
|
public List<MarkLabelCalcResult> GetMarkLabelCalcResultList(long cameraId) |
|
|
|
{ |
|
|
|
bool ret = MarkSearcherDict.TryGetValue(cameraId, out MarkSearcherBase markSearcher); |
|
|
|
return ret ? markSearcher.GetMarkLabelCalcResultList() : new List<MarkLabelCalcResult>(); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion Base Method
|
|
|
|
|
|
|
|
#region Base Method Async
|
|
|
|
|
|
|
|
public async Task<bool> ActivateSearcherAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return ActivateSearcher(cameraId); |
|
|
|
}); |
|
|
|
return await Task.Run(() => ActivateSearcher(cameraId)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> DeactivateSearcherAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return DeactivateSearcher(cameraId); |
|
|
|
}); |
|
|
|
return await Task.Run(() => DeactivateSearcher(cameraId)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> IsExistsSearcherAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return IsExistsSearcher(cameraId); |
|
|
|
}); |
|
|
|
return await Task.Run(() => IsExistsSearcher(cameraId)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<MarkSearcherBase> GetSearcherAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return GetSearcher(cameraId); |
|
|
|
}); |
|
|
|
return await Task.Run(() => GetSearcher(cameraId)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> ActivateMarkLabelAsync(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return ActivateMarkLabel(cameraId, markLabelId); |
|
|
|
}); |
|
|
|
return await Task.Run(() => ActivateMarkLabel(cameraId, markLabelId)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> DeactivateMarkLabelAsync(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return DeactivateMarkLabel(cameraId, markLabelId); |
|
|
|
}); |
|
|
|
return await Task.Run(() => DeactivateMarkLabel(cameraId, markLabelId)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<bool> IsExistsMarkLabelAsync(long cameraId, long markLabelId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => |
|
|
|
{ |
|
|
|
return IsExistsMarkLabel(cameraId, markLabelId); |
|
|
|
}); |
|
|
|
return await Task.Run(() => IsExistsMarkLabel(cameraId, markLabelId)); |
|
|
|
} |
|
|
|
|
|
|
|
public async Task<List<MarkLabelCalcResult>> GetMarkLabelCalcResultListAsync(long cameraId) |
|
|
|
{ |
|
|
|
return await Task.Run(() => GetMarkLabelCalcResultList(cameraId)); |
|
|
|
} |
|
|
|
|
|
|
|
#endregion Base Method Async
|
|
|
|