mirror of https://github.com/zlatinb/muwire
Make the number of hashing threads configurable, GitHub issue #57
parent
228a92a58d
commit
b1af2e557b
|
@ -29,6 +29,7 @@ class MuWireSettings {
|
|||
CrawlerResponse crawlerResponse
|
||||
boolean shareDownloadedFiles
|
||||
boolean shareHiddenFiles
|
||||
int hashingCores
|
||||
boolean searchComments
|
||||
boolean searchCollections
|
||||
boolean browseFiles
|
||||
|
@ -98,6 +99,7 @@ class MuWireSettings {
|
|||
updateType = props.getProperty("updateType","jar")
|
||||
shareDownloadedFiles = Boolean.parseBoolean(props.getProperty("shareDownloadedFiles","true"))
|
||||
shareHiddenFiles = Boolean.parseBoolean(props.getProperty("shareHiddenFiles","false"))
|
||||
hashingCores = Integer.parseInt(props.getProperty("hashingCores", String.valueOf(numHashingCores())))
|
||||
downloadSequentialRatio = Float.valueOf(props.getProperty("downloadSequentialRatio","0.8"))
|
||||
hostClearInterval = Integer.valueOf(props.getProperty("hostClearInterval","15"))
|
||||
hostHopelessInterval = Integer.valueOf(props.getProperty("hostHopelessInterval", "60"))
|
||||
|
@ -189,6 +191,7 @@ class MuWireSettings {
|
|||
props.setProperty("updateType",String.valueOf(updateType))
|
||||
props.setProperty("shareDownloadedFiles", String.valueOf(shareDownloadedFiles))
|
||||
props.setProperty("shareHiddenFiles", String.valueOf(shareHiddenFiles))
|
||||
props.setProperty("hashingCores", String.valueOf(hashingCores))
|
||||
props.setProperty("downloadSequentialRatio", String.valueOf(downloadSequentialRatio))
|
||||
props.setProperty("hostClearInterval", String.valueOf(hostClearInterval))
|
||||
props.setProperty("hostHopelessInterval", String.valueOf(hostHopelessInterval))
|
||||
|
@ -283,4 +286,8 @@ class MuWireSettings {
|
|||
String getNickname() {
|
||||
nickname
|
||||
}
|
||||
|
||||
private static int numHashingCores() {
|
||||
return (int) Math.max(1d, Runtime.getRuntime().availableProcessors() / 2d)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -34,7 +34,7 @@ class HasherService {
|
|||
}
|
||||
|
||||
void start() {
|
||||
executor = Executors.newFixedThreadPool((int)Math.max(1d, Runtime.getRuntime().availableProcessors() / 2d ))
|
||||
executor = Executors.newFixedThreadPool(settings.hashingCores)
|
||||
}
|
||||
|
||||
void onFileSharedEvent(FileSharedEvent evt) {
|
||||
|
|
|
@ -103,6 +103,10 @@ class OptionsController {
|
|||
boolean shareHidden = view.shareHiddenCheckbox.model.isSelected()
|
||||
model.shareHiddenFiles = shareHidden
|
||||
settings.shareHiddenFiles = shareHidden
|
||||
|
||||
int hashingCores = Integer.parseInt(view.hashingCoresTextField.text)
|
||||
model.hashingCores = hashingCores
|
||||
settings.hashingCores = hashingCores
|
||||
|
||||
boolean browseFiles = view.browseFilesCheckbox.model.isSelected()
|
||||
model.browseFiles = browseFiles
|
||||
|
|
|
@ -296,6 +296,7 @@ OPTIONS_UPLOAD_SLOTS_PER_USER=Upload slots per user (-1 means unlimited)
|
|||
OPTIONS_SHARING_SETTINGS=Sharing Settings
|
||||
OPTIONS_SHARE_DOWNLOADED_FILES=Share downloaded files
|
||||
OPTIONS_SHARE_HIDDEN_FILES=Share hidden files
|
||||
OPTIONS_HASHING_CORES=CPU Cores to use when hashing (changes require restart)
|
||||
OPTIONS_UPDATE_SETTINGS=Update Settings
|
||||
OPTIONS_CHECK_FOR_UPDATES=Check for updates every (hours)
|
||||
OPTIONS_DOWNLOAD_UPDATES=Download updates automatically
|
||||
|
|
|
@ -17,6 +17,7 @@ class OptionsModel {
|
|||
@Observable boolean autoDownloadUpdate
|
||||
@Observable boolean shareDownloadedFiles
|
||||
@Observable boolean shareHiddenFiles
|
||||
@Observable int hashingCores
|
||||
@Observable String downloadLocation
|
||||
@Observable String incompleteLocation
|
||||
@Observable boolean searchComments
|
||||
|
@ -95,6 +96,7 @@ class OptionsModel {
|
|||
autoDownloadUpdate = settings.autoDownloadUpdate
|
||||
shareDownloadedFiles = settings.shareDownloadedFiles
|
||||
shareHiddenFiles = settings.shareHiddenFiles
|
||||
hashingCores = settings.hashingCores
|
||||
downloadLocation = settings.downloadLocation.getAbsolutePath()
|
||||
incompleteLocation = settings.incompleteLocation.getAbsolutePath()
|
||||
searchComments = settings.searchComments
|
||||
|
|
|
@ -49,6 +49,7 @@ class OptionsView {
|
|||
def autoDownloadUpdateCheckbox
|
||||
def shareDownloadedCheckbox
|
||||
def shareHiddenCheckbox
|
||||
def hashingCoresTextField
|
||||
def searchCommentsCheckbox
|
||||
def searchCollectionsCheckbox
|
||||
def browseFilesCheckbox
|
||||
|
@ -172,6 +173,10 @@ class OptionsView {
|
|||
|
||||
label(text : trans("OPTIONS_SHARE_HIDDEN_FILES"), constraints : gbc(gridx : 0, gridy:1, anchor : GridBagConstraints.LINE_START, weightx : 100))
|
||||
shareHiddenCheckbox = checkBox(selected : bind {model.shareHiddenFiles}, constraints : gbc(gridx :1, gridy:1, weightx : 0))
|
||||
|
||||
label(text : trans("OPTIONS_HASHING_CORES"), constraints : gbc(gridx: 0 , gridy : 2, anchor : GridBagConstraints.LINE_START, weightx : 100))
|
||||
hashingCoresTextField = textField(text : bind {model.hashingCores}, columns: 2,
|
||||
constraints: gbc(gridx: 1, gridy: 2, anchor: GridBagConstraints.LINE_END))
|
||||
}
|
||||
|
||||
if (!model.disableUpdates) {
|
||||
|
|
Loading…
Reference in New Issue