Atomics.isLockFree()

Baseline Widely available

This feature is well established and works across many devices and browser versions. It’s been available across browsers since December 2021.

La méthode statique Atomics.isLockFree() est utilisée afin de déterminer si on doit utiliser des verrous (locks) ou des opérations atomiques. Elle renvoie true si la taille donnée correspond à une des propriétés BYTES_PER_ELEMENT d'un des types TypedArray.

Exemple interactif

console.log(Atomics.isLockFree(3));
// 3 is not one of the BYTES_PER_ELEMENT values
// Expected output: false

console.log(Atomics.isLockFree(4));
// 4 is one of the BYTES_PER_ELEMENT values
// Expected output: true

Syntaxe

js
Atomics.isLockFree(taille);

Paramètres

taille

La taille en octets qu'on souhaite vérifier.

Valeur de retour

Un booléen indiquant si l'opération se déroule sans verrou.

Exemples

js
Atomics.isLockFree(1); // true
Atomics.isLockFree(2); // true
Atomics.isLockFree(3); // false
Atomics.isLockFree(4); // true
Atomics.isLockFree(5); // false
Atomics.isLockFree(6); // false
Atomics.isLockFree(7); // false
Atomics.isLockFree(8); // true

Spécifications

Specification
ECMAScript® 2025 Language Specification
# sec-atomics.islockfree

Compatibilité des navigateurs

Report problems with this compatibility data on GitHub
desktopmobileserver
Chrome
Edge
Firefox
Opera
Safari
Chrome Android
Firefox for Android
Opera Android
Safari on iOS
Samsung Internet
WebView Android
WebView on iOS
Deno
Node.js
isLockFree

Legend

Tip: you can click/tap on a cell for more information.

Full support
Full support

Voir aussi