use worker to avoid freezing
This commit is contained in:
@@ -14,7 +14,17 @@ GNU General Public License for more details.
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
import { modinv, modpow, modsqrt, ord } from "./math.js";
|
||||
importScripts("./math.js")
|
||||
|
||||
addEventListener("message", (message) => {
|
||||
if (message.data.command === "compute") {
|
||||
try {
|
||||
compute(message.data.queue, message.data.m);
|
||||
} catch(e) {
|
||||
postMessage(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
function binaryOpPop(stack) {
|
||||
const b = stack.pop();
|
||||
@@ -88,7 +98,5 @@ function compute(queue, modulus) {
|
||||
result += modulus;
|
||||
}
|
||||
|
||||
return result;
|
||||
postMessage(result);
|
||||
}
|
||||
|
||||
export { compute };
|
||||
|
||||
@@ -220,5 +220,3 @@ function ord(n, modulus) {
|
||||
|
||||
return k;
|
||||
}
|
||||
|
||||
export { modsqrt, modinv, modpow, ord };
|
||||
|
||||
Reference in New Issue
Block a user