diff options
Diffstat (limited to 'cli')
-rw-r--r-- | cli/diagnostics.rs | 2 | ||||
-rw-r--r-- | cli/dts/lib.deno.unstable.d.ts | 23 | ||||
-rw-r--r-- | cli/dts/lib.deno.window.d.ts | 1 | ||||
-rw-r--r-- | cli/dts/lib.deno.worker.d.ts | 1 | ||||
-rw-r--r-- | cli/main.rs | 2 | ||||
-rw-r--r-- | cli/standalone.rs | 1 | ||||
-rw-r--r-- | cli/tests/unit/navigator_test.ts | 6 | ||||
-rw-r--r-- | cli/tests/unit/os_test.ts | 6 |
8 files changed, 11 insertions, 31 deletions
diff --git a/cli/diagnostics.rs b/cli/diagnostics.rs index da9a090c8..9d1faa6b1 100644 --- a/cli/diagnostics.rs +++ b/cli/diagnostics.rs @@ -40,7 +40,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "Signal", "SignalStream", "StartTlsOptions", - "SystemCpuInfo", "SystemMemoryInfo", "UnixConnectOptions", "UnixListenOptions", @@ -68,7 +67,6 @@ const UNSTABLE_DENO_PROPS: &[&str] = &[ "signals", "sleepSync", "startTls", - "systemCpuInfo", "systemMemoryInfo", "umask", "utime", diff --git a/cli/dts/lib.deno.unstable.d.ts b/cli/dts/lib.deno.unstable.d.ts index 199f05631..442da1e53 100644 --- a/cli/dts/lib.deno.unstable.d.ts +++ b/cli/dts/lib.deno.unstable.d.ts @@ -107,29 +107,6 @@ declare namespace Deno { swapFree: number; } - /** **Unstable** new API. yet to be vetted. - * - * Returns the total number of logical cpus in the system along with - * the speed measured in MHz. If either the syscall to get the core - * count or speed of the cpu is unsuccessful the value of the it - * is undefined. - * - * ```ts - * console.log(Deno.systemCpuInfo()); - * ``` - * - * Requires `allow-env` permission. - * - */ - export function systemCpuInfo(): SystemCpuInfo; - - export interface SystemCpuInfo { - /** Total number of logical cpus in the system */ - cores: number | undefined; - /** The speed of the cpu measured in MHz */ - speed: number | undefined; - } - /** **UNSTABLE**: new API, yet to be vetted. * * Open and initialize a plugin. diff --git a/cli/dts/lib.deno.window.d.ts b/cli/dts/lib.deno.window.d.ts index 00100768b..e515c19b7 100644 --- a/cli/dts/lib.deno.window.d.ts +++ b/cli/dts/lib.deno.window.d.ts @@ -37,6 +37,7 @@ declare var sessionStorage: Storage; declare class Navigator { constructor(); readonly gpu: GPU; + readonly hardwareConcurrency: number; } declare var navigator: Navigator; diff --git a/cli/dts/lib.deno.worker.d.ts b/cli/dts/lib.deno.worker.d.ts index 7d8f6078b..d35828135 100644 --- a/cli/dts/lib.deno.worker.d.ts +++ b/cli/dts/lib.deno.worker.d.ts @@ -50,6 +50,7 @@ declare class WorkerGlobalScope extends EventTarget { declare class WorkerNavigator { constructor(); readonly gpu: GPU; + readonly hardwareConcurrency: number; } declare var navigator: WorkerNavigator; diff --git a/cli/main.rs b/cli/main.rs index bb7e03041..52f2c55af 100644 --- a/cli/main.rs +++ b/cli/main.rs @@ -126,6 +126,7 @@ fn create_web_worker_callback( shared_array_buffer_store: Some( program_state.shared_array_buffer_store.clone(), ), + cpu_count: num_cpus::get(), }; let (mut worker, external_handle) = WebWorker::from_options( @@ -215,6 +216,7 @@ pub fn create_main_worker( shared_array_buffer_store: Some( program_state.shared_array_buffer_store.clone(), ), + cpu_count: num_cpus::get(), }; let mut worker = MainWorker::from_options(main_module, permissions, &options); diff --git a/cli/standalone.rs b/cli/standalone.rs index c8918563f..65ca58ec3 100644 --- a/cli/standalone.rs +++ b/cli/standalone.rs @@ -249,6 +249,7 @@ pub async fn run( blob_store, broadcast_channel, shared_array_buffer_store: None, + cpu_count: num_cpus::get(), }; let mut worker = MainWorker::from_options(main_module.clone(), permissions, &options); diff --git a/cli/tests/unit/navigator_test.ts b/cli/tests/unit/navigator_test.ts new file mode 100644 index 000000000..10475d973 --- /dev/null +++ b/cli/tests/unit/navigator_test.ts @@ -0,0 +1,6 @@ +// Copyright 2018-2021 the Deno authors. All rights reserved. MIT license. +import { assert, unitTest } from "./test_util.ts"; + +unitTest(function navigatorNumCpus(): void { + assert(navigator.hardwareConcurrency > 0); +}); diff --git a/cli/tests/unit/os_test.ts b/cli/tests/unit/os_test.ts index 9b0f71352..daa7a1ca2 100644 --- a/cli/tests/unit/os_test.ts +++ b/cli/tests/unit/os_test.ts @@ -203,9 +203,3 @@ unitTest({ perms: { env: true } }, function systemMemoryInfo(): void { assert(info.swapTotal >= 0); assert(info.swapFree >= 0); }); - -unitTest({ perms: { env: true } }, function systemCpuInfo(): void { - const { cores, speed } = Deno.systemCpuInfo(); - assert(cores === undefined || cores > 0); - assert(speed === undefined || speed > 0); -}); |