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