Use worker threads for sudoku generation
Moves sudoku generation off of the main thread. Allows for multiple generation requests (up to the number of physical CPU cores) to be served in parallel. Uses the "physical-cpu-count" node package to determine the numer of physical CPUs of the host. Also introduces a timeout which causes too-difficult (or impossible) generation requests to fail if they take more than 5 seconds to complete. In effect soft-capping the complexity of generated puzzles.
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
import { gql } from "../mods";
|
||||
import { generate } from "../sudoku/index";
|
||||
import { generate, GenerateArguments } from "../sudoku/index";
|
||||
|
||||
export const typeDefs = gql`
|
||||
type Cell {
|
||||
@ -37,12 +37,6 @@ export const typeDefs = gql`
|
||||
}
|
||||
`;
|
||||
|
||||
type GenerateArguments = {
|
||||
regionWidth: number;
|
||||
regionHeight: number;
|
||||
clues: number;
|
||||
};
|
||||
|
||||
export const resolvers = {
|
||||
Query: {
|
||||
generate: (
|
||||
|
Reference in New Issue
Block a user