From 959ec23a606ec522179d28147a34d15a36a1f303 Mon Sep 17 00:00:00 2001 From: Derek Howard Date: Wed, 25 Mar 2015 09:02:04 -0500 Subject: [PATCH 1/4] Default number of threads the number of cores --- multithread.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/multithread.js b/multithread.js index d8d37c0..78bace0 100644 --- a/multithread.js +++ b/multithread.js @@ -10,7 +10,7 @@ } function Multithread(threads) { - this.threads = Math.max(2, threads | 0); + this.threads = Math.max(2, threads | 0, navigator.hardwareConcurrency | 0); this._queue = []; this._queueSize = 0; this._activeThreads = 0; @@ -266,4 +266,4 @@ window['Multithread'] = Multithread; -}(); \ No newline at end of file +}(); From 1eb57f4617d532cc4e5bcf04f926204d07aaa787 Mon Sep 17 00:00:00 2001 From: Derek Howard Date: Thu, 26 Mar 2015 11:04:50 -0500 Subject: [PATCH 2/4] Update multithread.js --- multithread.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multithread.js b/multithread.js index 78bace0..2d08bcf 100644 --- a/multithread.js +++ b/multithread.js @@ -10,7 +10,7 @@ } function Multithread(threads) { - this.threads = Math.max(2, threads | 0, navigator.hardwareConcurrency | 0); + this.threads = Math.max((typeof threads !== 'undefined') ? threads: (typeof navigator.hardwareConcurrency !== 'undefined') ? navigator.hardwareConcurrency : 2); this._queue = []; this._queueSize = 0; this._activeThreads = 0; From 4129798948e2b52bdd61fac3c3a7a60602b3c040 Mon Sep 17 00:00:00 2001 From: Derek Howard Date: Thu, 26 Mar 2015 11:05:29 -0500 Subject: [PATCH 3/4] Update multithread.js From 89a3f8b76a5798ab48a0996c99ab02b9d605afd8 Mon Sep 17 00:00:00 2001 From: Derek Howard Date: Fri, 27 Mar 2015 14:53:52 -0500 Subject: [PATCH 4/4] Stopped using Math.max --- multithread.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/multithread.js b/multithread.js index 2d08bcf..596ca10 100644 --- a/multithread.js +++ b/multithread.js @@ -10,7 +10,7 @@ } function Multithread(threads) { - this.threads = Math.max((typeof threads !== 'undefined') ? threads: (typeof navigator.hardwareConcurrency !== 'undefined') ? navigator.hardwareConcurrency : 2); + this.threads = (typeof threads !== 'undefined') ? threads: (typeof navigator.hardwareConcurrency !== 'undefined') ? navigator.hardwareConcurrency : 2 this._queue = []; this._queueSize = 0; this._activeThreads = 0;