Skip to content

Commit

Permalink
chore: fix lint (2)
Browse files Browse the repository at this point in the history
  • Loading branch information
Nek-12 committed Dec 8, 2024
1 parent 12f412e commit 588e694
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,9 @@ import kotlinx.coroutines.yield
import pro.respawn.flowmvi.benchmarks.setup.BenchmarkIntent.Increment
import pro.respawn.flowmvi.benchmarks.setup.atomic.atomicParallelStore

/**
* run an infinite process for profiling
*/
fun main() = runBlocking {
println(ProcessHandle.current().pid())
val store = atomicParallelStore(this)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ package pro.respawn.flowmvi.benchmarks.setup

import pro.respawn.flowmvi.api.MVIState

data class BenchmarkState(
internal data class BenchmarkState(
val counter: Int = 0
) : MVIState
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import org.openjdk.jmh.annotations.Threads
@Threads(Threads.MAX)
@Suppress("unused")
@State(Scope.Benchmark)
class FluxoStartStopBenchmark {
internal class FluxoStartStopBenchmark {

@OptIn(ExperimentalFluxoApi::class)
@Benchmark
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,14 +2,20 @@ package pro.respawn.flowmvi.api

import kotlinx.coroutines.flow.StateFlow
import pro.respawn.flowmvi.annotation.InternalFlowMVIAPI
import pro.respawn.flowmvi.dsl.updateStateImmediate

/**
* [StateReceiver] version that can only accept immediate state updates. It is recommended to use [StateReceiver] and
* its methods if possible. See the method docs for details
*/
public interface ImmediateStateReceiver<S : MVIState> : StateProvider<S> {

@FlowMVIDSL
/**
* Directly compare and set the current state.
*
* Please read [updateStateImmediate] to learn about repercussions of using this.
*/
@InternalFlowMVIAPI
public fun compareAndSet(old: S, new: S): Boolean

@InternalFlowMVIAPI
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package pro.respawn.flowmvi.dsl

import pro.respawn.flowmvi.annotation.InternalFlowMVIAPI
import pro.respawn.flowmvi.api.DelicateStoreApi
import pro.respawn.flowmvi.api.FlowMVIDSL
import pro.respawn.flowmvi.api.ImmediateStateReceiver
Expand Down Expand Up @@ -42,17 +43,15 @@ public inline val <S : MVIState> StateProvider<S>.state get() = states.value
* @see StateReceiver.updateState
* @see StateReceiver.withState
*/
@OptIn(DelicateStoreApi::class)
@OptIn(DelicateStoreApi::class, InternalFlowMVIAPI::class)
@FlowMVIDSL
public inline fun <S : MVIState> ImmediateStateReceiver<S>.updateStateImmediate(
@BuilderInference transform: S.() -> S
) {
contract {
callsInPlace(transform, InvocationKind.AT_LEAST_ONCE)
}
while (true) {
if (compareAndSet(state, transform(state))) return
}
while (true) if (compareAndSet(state, transform(state))) return
}

/**
Expand Down

0 comments on commit 588e694

Please sign in to comment.