lib.es2017.sharedmemory.d.ts 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137
  1. /*! *****************************************************************************
  2. Copyright (c) Microsoft Corporation. All rights reserved.
  3. Licensed under the Apache License, Version 2.0 (the "License"); you may not use
  4. this file except in compliance with the License. You may obtain a copy of the
  5. License at http://www.apache.org/licenses/LICENSE-2.0
  6. THIS CODE IS PROVIDED ON AN *AS IS* BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
  7. KIND, EITHER EXPRESS OR IMPLIED, INCLUDING WITHOUT LIMITATION ANY IMPLIED
  8. WARRANTIES OR CONDITIONS OF TITLE, FITNESS FOR A PARTICULAR PURPOSE,
  9. MERCHANTABLITY OR NON-INFRINGEMENT.
  10. See the Apache Version 2.0 License for specific language governing permissions
  11. and limitations under the License.
  12. ***************************************************************************** */
  13. /// <reference no-default-lib="true"/>
  14. /// <reference lib="es2015.symbol" />
  15. /// <reference lib="es2015.symbol.wellknown" />
  16. interface SharedArrayBuffer {
  17. /**
  18. * Read-only. The length of the ArrayBuffer (in bytes).
  19. */
  20. readonly byteLength: number;
  21. /**
  22. * Returns a section of an SharedArrayBuffer.
  23. */
  24. slice(begin: number, end?: number): SharedArrayBuffer;
  25. readonly [Symbol.species]: SharedArrayBuffer;
  26. readonly [Symbol.toStringTag]: "SharedArrayBuffer";
  27. }
  28. interface SharedArrayBufferConstructor {
  29. readonly prototype: SharedArrayBuffer;
  30. new (byteLength: number): SharedArrayBuffer;
  31. }
  32. declare var SharedArrayBuffer: SharedArrayBufferConstructor;
  33. interface ArrayBufferTypes {
  34. SharedArrayBuffer: SharedArrayBuffer;
  35. }
  36. interface Atomics {
  37. /**
  38. * Adds a value to the value at the given position in the array, returning the original value.
  39. * Until this atomic operation completes, any other read or write operation against the array
  40. * will block.
  41. */
  42. add(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
  43. /**
  44. * Stores the bitwise AND of a value with the value at the given position in the array,
  45. * returning the original value. Until this atomic operation completes, any other read or
  46. * write operation against the array will block.
  47. */
  48. and(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
  49. /**
  50. * Replaces the value at the given position in the array if the original value equals the given
  51. * expected value, returning the original value. Until this atomic operation completes, any
  52. * other read or write operation against the array will block.
  53. */
  54. compareExchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, expectedValue: number, replacementValue: number): number;
  55. /**
  56. * Replaces the value at the given position in the array, returning the original value. Until
  57. * this atomic operation completes, any other read or write operation against the array will
  58. * block.
  59. */
  60. exchange(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
  61. /**
  62. * Returns a value indicating whether high-performance algorithms can use atomic operations
  63. * (`true`) or must use locks (`false`) for the given number of bytes-per-element of a typed
  64. * array.
  65. */
  66. isLockFree(size: number): boolean;
  67. /**
  68. * Returns the value at the given position in the array. Until this atomic operation completes,
  69. * any other read or write operation against the array will block.
  70. */
  71. load(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number): number;
  72. /**
  73. * Stores the bitwise OR of a value with the value at the given position in the array,
  74. * returning the original value. Until this atomic operation completes, any other read or write
  75. * operation against the array will block.
  76. */
  77. or(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
  78. /**
  79. * Stores a value at the given position in the array, returning the new value. Until this
  80. * atomic operation completes, any other read or write operation against the array will block.
  81. */
  82. store(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
  83. /**
  84. * Subtracts a value from the value at the given position in the array, returning the original
  85. * value. Until this atomic operation completes, any other read or write operation against the
  86. * array will block.
  87. */
  88. sub(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
  89. /**
  90. * If the value at the given position in the array is equal to the provided value, the current
  91. * agent is put to sleep causing execution to suspend until the timeout expires (returning
  92. * `"timed-out"`) or until the agent is awoken (returning `"ok"`); otherwise, returns
  93. * `"not-equal"`.
  94. */
  95. wait(typedArray: Int32Array, index: number, value: number, timeout?: number): "ok" | "not-equal" | "timed-out";
  96. /**
  97. * Wakes up sleeping agents that are waiting on the given index of the array, returning the
  98. * number of agents that were awoken.
  99. * @param typedArray A shared Int32Array.
  100. * @param index The position in the typedArray to wake up on.
  101. * @param count The number of sleeping agents to notify. Defaults to +Infinity.
  102. */
  103. notify(typedArray: Int32Array, index: number, count?: number): number;
  104. /**
  105. * Stores the bitwise XOR of a value with the value at the given position in the array,
  106. * returning the original value. Until this atomic operation completes, any other read or write
  107. * operation against the array will block.
  108. */
  109. xor(typedArray: Int8Array | Uint8Array | Int16Array | Uint16Array | Int32Array | Uint32Array, index: number, value: number): number;
  110. readonly [Symbol.toStringTag]: "Atomics";
  111. }
  112. declare var Atomics: Atomics;