Skip to content

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

Open
wants to merge 2 commits into
base: experimental/improved-download-unpacking-installation
Choose a base branch
from

Conversation

Szczyrk
Copy link
Collaborator

@Szczyrk Szczyrk commented Aug 24, 2021

No description provided.

@Szczyrk Szczyrk changed the base branch from dev/v3.17.x.x to experimental/improved-download-unpacking-installation August 27, 2021 12:05
catch (Exception e)
{
DebugLogger.LogError(e.ToString());
throw;
Copy link
Contributor

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;
Copy link
Contributor

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)
Copy link
Contributor

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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for (int i = 0; i < _versionSummary.Files.Length; i++)
files = new FileIntegrity[_versionSummary.Files.Length];
int i = 0;
foreach (var file in _versionSummary.Files)
Copy link
Contributor

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).

Copy link
Collaborator Author

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;
Copy link
Contributor

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;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can be threadFileIndex.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants