-
Notifications
You must be signed in to change notification settings - Fork 516
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #3247 from djspiewak/release/3.4.0-major
Backport merge 3.4.0 into major branch
- Loading branch information
Showing
60 changed files
with
1,319 additions
and
371 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,62 @@ | ||
/* | ||
* Copyright 2020-2022 Typelevel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cats.effect | ||
|
||
import scala.scalajs.js | ||
|
||
private final class ArrayStack[A <: AnyRef](val buffer: js.Array[A]) extends AnyVal { | ||
|
||
@inline def init(bound: Int): Unit = { | ||
val _ = bound | ||
() | ||
} | ||
|
||
@inline def push(a: A): Unit = { | ||
buffer.push(a) | ||
() | ||
} | ||
|
||
@inline def pop(): A = { | ||
buffer.pop() | ||
} | ||
|
||
@inline def peek(): A = buffer(buffer.length - 1) | ||
|
||
@inline def isEmpty(): Boolean = buffer.length == 0 | ||
|
||
// to allow for external iteration | ||
@inline def unsafeBuffer(): js.Array[A] = buffer | ||
@inline def unsafeIndex(): Int = buffer.length | ||
|
||
@inline def invalidate(): Unit = { | ||
buffer.length = 0 // javascript is crazy! | ||
} | ||
|
||
} | ||
|
||
private object ArrayStack { | ||
|
||
@inline def apply[A <: AnyRef](size: Int): ArrayStack[A] = { | ||
val _ = size | ||
apply() | ||
} | ||
|
||
@inline def apply[A <: AnyRef](): ArrayStack[A] = { | ||
new ArrayStack(new js.Array[A]) | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
/* | ||
* Copyright 2020-2022 Typelevel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cats.effect | ||
|
||
import scala.scalajs.js | ||
|
||
private object ByteStack { | ||
|
||
type T = js.Array[Int] | ||
|
||
@inline final def create(initialMaxOps: Int): js.Array[Int] = { | ||
val _ = initialMaxOps | ||
js.Array(0) | ||
} | ||
|
||
@inline final def growIfNeeded(stack: js.Array[Int], count: Int): js.Array[Int] = { | ||
if ((1 + ((count + 1) >> 3)) < stack.length) { | ||
stack | ||
} else { | ||
stack.push(0) | ||
stack | ||
} | ||
} | ||
|
||
@inline final def push(stack: js.Array[Int], op: Byte): js.Array[Int] = { | ||
val c = stack(0) // current count of elements | ||
val use = growIfNeeded(stack, c) // alias so we add to the right place | ||
val s = (c >> 3) + 1 // current slot in `use` | ||
val shift = (c & 7) << 2 // BEGIN MAGIC | ||
use(s) = (use(s) & ~(0xffffffff << shift)) | (op << shift) // END MAGIC | ||
use(0) += 1 // write the new count | ||
use | ||
} | ||
|
||
@inline final def size(stack: js.Array[Int]): Int = | ||
stack(0) | ||
|
||
@inline final def isEmpty(stack: js.Array[Int]): Boolean = | ||
stack(0) < 1 | ||
|
||
@inline final def read(stack: js.Array[Int], pos: Int): Byte = { | ||
if (pos < 0 || pos >= stack(0)) throw new ArrayIndexOutOfBoundsException() | ||
((stack((pos >> 3) + 1) >>> ((pos & 7) << 2)) & 0x0000000f).toByte | ||
} | ||
|
||
@inline final def peek(stack: js.Array[Int]): Byte = { | ||
val c = stack(0) - 1 | ||
if (c < 0) throw new ArrayIndexOutOfBoundsException() | ||
((stack((c >> 3) + 1) >>> ((c & 7) << 2)) & 0x0000000f).toByte | ||
} | ||
|
||
@inline final def pop(stack: js.Array[Int]): Byte = { | ||
val op = peek(stack) | ||
stack(0) -= 1 | ||
op | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
31 changes: 31 additions & 0 deletions
31
core/js/src/main/scala/cats/effect/metrics/JsCpuStarvationMetrics.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
/* | ||
* Copyright 2020-2022 Typelevel | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
package cats.effect.metrics | ||
|
||
import cats.effect.IO | ||
|
||
import scala.concurrent.duration.FiniteDuration | ||
|
||
private[effect] class JsCpuStarvationMetrics extends CpuStarvationMetrics { | ||
override def incCpuStarvationCount: IO[Unit] = IO.unit | ||
|
||
override def recordClockDrift(drift: FiniteDuration): IO[Unit] = IO.unit | ||
} | ||
|
||
private[effect] object JsCpuStarvationMetrics { | ||
private[effect] def apply(): CpuStarvationMetrics = new JsCpuStarvationMetrics | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.