Skip to content

Commit 72e487d

Browse files
author
sshevchenko
committed
Fix Codacy warnings.
1 parent 536ac82 commit 72e487d

4 files changed

Lines changed: 13 additions & 9 deletions

File tree

benchmark/src/main/scala/com/evolutiongaming/concurrent/sequentially/SequentiallyCatsVsAkkaBenchmark.scala

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ class SequentiallyCatsVsAkkaBenchmark extends Common {
5050
implicit val ec: scala.concurrent.ExecutionContext = akkaSystem.dispatcher
5151
val futures = List.fill(BatchSize)(akkaSequentially(Random.nextInt()) {})
5252
Await.result(Future.sequence(futures), 10.seconds)
53+
()
5354
}
5455

5556
@Benchmark
@@ -58,13 +59,15 @@ class SequentiallyCatsVsAkkaBenchmark extends Common {
5859
catsSequentially.applyF(Random.nextInt())(IO.unit)
5960
)
6061
operations.sequence.unsafeRunSync()(runtime)
62+
()
6163
}
6264

6365
@Benchmark
6466
def catsApplyFuture(): Unit = {
6567
implicit val ec: scala.concurrent.ExecutionContext = scala.concurrent.ExecutionContext.global
6668
val futures = List.fill(BatchSize)(catsSequentially(Random.nextInt()) {}(dispatcher))
6769
Await.result(Future.sequence(futures), 10.seconds)
70+
()
6871
}
6972

7073
@TearDown(Level.Trial)

run-benchmarks.sh

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66
set -e
77

8-
# Colors for output
9-
RED='\033[0;31m'
8+
# Colors for outputCodacy
109
GREEN='\033[0;32m'
1110
YELLOW='\033[1;33m'
1211
BLUE='\033[0;34m'

sequentially-ce/src/main/scala/com/evolutiongaming/concurrent/sequentially/SequentiallyF.scala

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,8 @@ import scala.concurrent.Future
1414
* - Number of buckets: (availableProcessors max 1) * 5
1515
* - All semaphores are pre-allocated at initialization
1616
*/
17-
final class SequentiallyF[F[_], K] private (
17+
final class SequentiallyF[F[_] : Async, K] private (
1818
semaphores: Vector[Semaphore[F]]
19-
)(implicit
20-
F: Async[F]
2119
) {
2220

2321
private val bucketCount = semaphores.size
@@ -45,7 +43,7 @@ final class SequentiallyF[F[_], K] private (
4543
dispatcher: Dispatcher[F]
4644
): Future[T] = {
4745
val semaphore = semaphores(getBucket(key))
48-
val run: F[T] = semaphore.permit.use(_ => F.delay(task))
46+
val run: F[T] = semaphore.permit.use(_ => Async[F].delay(task))
4947
dispatcher.unsafeToFuture(run)
5048
}
5149

sequentially-ce/src/test/scala/com/evolutiongaming/concurrent/sequentially/SequentiallyCatsSpec.scala

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,12 @@ class SequentiallyFSpec extends AnyWordSpec with Matchers with ScalaFutures with
2121
interval = Span(50, Millis),
2222
)
2323

24-
implicit val dispatcher: Dispatcher[IO] =
25-
Dispatcher.parallel[IO].allocated.unsafeRunSync()(IORuntime.global)._1
24+
implicit val dispatcher: Dispatcher[IO] = createDispatcher
25+
26+
private def createDispatcher: Dispatcher[IO] = {
27+
val (dispatcher, _) = Dispatcher.parallel[IO].allocated.unsafeRunSync()(IORuntime.global)
28+
dispatcher
29+
}
2630

2731
"SequentiallyF" should {
2832

@@ -170,7 +174,7 @@ class SequentiallyFSpec extends AnyWordSpec with Matchers with ScalaFutures with
170174
val semaphores = List.fill(bucketCount)(Semaphore[IO](1)).sequence.map(_.toVector).unsafeRunSync()
171175
implicit val (dispatcher: Dispatcher[IO], dispatcherCleanup: IO[Unit]) =
172176
Dispatcher.parallel[IO].allocated.unsafeRunSync()
173-
val sequentially = SequentiallyF.resource[IO, Int](semaphores).allocated.unsafeRunSync()._1
177+
val (sequentially, _) = SequentiallyF.resource[IO, Int](semaphores).allocated.unsafeRunSync()
174178

175179
try {
176180
// Verify all semaphores are initialized

0 commit comments

Comments
 (0)