-
Notifications
You must be signed in to change notification settings - Fork 19
Added threadpool for check version integrity #176
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: experimental/improved-download-unpacking-installation
Are you sure you want to change the base?
Added threadpool for check version integrity #176
Conversation
catch (Exception e) | ||
{ | ||
DebugLogger.LogError(e.ToString()); | ||
throw; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't allow a thread to end up with an exception. A different solution is required here (like storing lastThreadException
that is checked sometimes and rethrown is not null
).
bool _isCheckingSize; | ||
private volatile bool _isCheckingHash; | ||
private volatile bool _isCheckingSize; | ||
private volatile int _space; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
_currentThreadCount
would be better there.
tmp = _space; | ||
} | ||
|
||
if (tmp < 16) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please introduce a constant MaxThreadCount
instead of 16
here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also, please consider semaphores - https://docs.microsoft.com/en-us/dotnet/api/system.threading.semaphore?view=net-5.0
for (int i = 0; i < _versionSummary.Files.Length; i++) | ||
files = new FileIntegrity[_versionSummary.Files.Length]; | ||
int i = 0; | ||
foreach (var file in _versionSummary.Files) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
for
can be reverted here, so only i
needs to be passed to the thread (_versionSummary.Files
is not modified anywhere so can be freely accessed from worker thread).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@genail you suggested using foreach
here because it works faster.
|
||
for (int i = 0; i < _versionSummary.Files.Length; i++) | ||
files = new FileIntegrity[_versionSummary.Files.Length]; | ||
int i = 0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be fileIndex
.
} | ||
|
||
var fileInThread = file; | ||
var number = i; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can be threadFileIndex
.
No description provided.