-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Linearizability support additionally to sequential consistency has be…
…en implemented
- Loading branch information
Showing
29 changed files
with
602 additions
and
457 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
77 changes: 0 additions & 77 deletions
77
lincheck/src/main/java/org/jetbrains/kotlinx/lincheck/execution/ExecutionResult.java
This file was deleted.
Oops, something went wrong.
59 changes: 59 additions & 0 deletions
59
lincheck/src/main/java/org/jetbrains/kotlinx/lincheck/execution/ExecutionResult.kt
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,59 @@ | ||
/*- | ||
* #%L | ||
* Lincheck | ||
* %% | ||
* Copyright (C) 2019 - 2020 JetBrains s.r.o. | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package org.jetbrains.kotlinx.lincheck.execution | ||
|
||
import org.jetbrains.kotlinx.lincheck.* | ||
|
||
/** | ||
* This class represents a result corresponding to | ||
* the specified [scenario][ExecutionScenario] execution. | ||
* | ||
* All the result parts should have the same dimensions as the scenario. | ||
*/ | ||
data class ExecutionResult( | ||
/** | ||
* Results of the initial sequential part of the execution. | ||
* @see ExecutionScenario.initExecution | ||
*/ | ||
val initResults: List<Result>, | ||
/** | ||
* Results of the parallel part of the execution with the clock values at the beginning of each one. | ||
* @see ExecutionScenario.parallelExecution | ||
*/ | ||
val parallelResultsWithClock: List<List<ResultWithClock>>, | ||
/** | ||
* Results of the last sequential part of the execution. | ||
* @see ExecutionScenario.postExecution | ||
*/ | ||
val postResults: List<Result> | ||
) | ||
|
||
val ExecutionResult.withEmptyClocks: ExecutionResult get() = ExecutionResult( | ||
this.initResults, | ||
this.parallelResultsWithClock.map { it.withEmptyClock() }, | ||
this.postResults | ||
) | ||
|
||
val ExecutionResult.parallelResults: List<List<Result>> get() = parallelResultsWithClock.map { it.map { r -> r.result } } | ||
|
||
// for tests | ||
fun ExecutionResult.equalsIgnoringClocks(other: ExecutionResult) = this.withEmptyClocks == other.withEmptyClocks |
50 changes: 50 additions & 0 deletions
50
lincheck/src/main/java/org/jetbrains/kotlinx/lincheck/execution/HBClock.kt
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,50 @@ | ||
/*- | ||
* #%L | ||
* Lincheck | ||
* %% | ||
* Copyright (C) 2019 - 2020 JetBrains s.r.o. | ||
* %% | ||
* This program is free software: you can redistribute it and/or modify | ||
* it under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation, either version 3 of the | ||
* License, or (at your option) any later version. | ||
* | ||
* This program is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
* GNU General Lesser Public License for more details. | ||
* | ||
* You should have received a copy of the GNU General Lesser Public | ||
* License along with this program. If not, see | ||
* <http://www.gnu.org/licenses/lgpl-3.0.html>. | ||
* #L% | ||
*/ | ||
package org.jetbrains.kotlinx.lincheck.execution | ||
|
||
import org.jetbrains.kotlinx.lincheck.Result | ||
|
||
data class HBClock(val clock: IntArray) { | ||
val threads: Int get() = clock.size | ||
val empty: Boolean get() = clock.all { it == 0 } | ||
operator fun get(i: Int) = clock[i] | ||
|
||
override fun toString()= clock.joinToString(prefix = "[", separator = ",", postfix = "]") | ||
|
||
override fun equals(other: Any?): Boolean { | ||
if (this === other) return true | ||
if (javaClass != other?.javaClass) return false | ||
other as HBClock | ||
return clock.contentEquals(other.clock) | ||
} | ||
|
||
override fun hashCode() = clock.contentHashCode() | ||
} | ||
|
||
fun emptyClock(size: Int) = HBClock(emptyClockArray(size)) | ||
fun emptyClockArray(size: Int) = IntArray(size) { 0 } | ||
|
||
data class ResultWithClock(val result: Result, val clockOnStart: HBClock) | ||
|
||
fun Result.withEmptyClock(threads: Int) = ResultWithClock(this, emptyClock(threads)) | ||
fun List<Result>.withEmptyClock(threads: Int): List<ResultWithClock> = map { it.withEmptyClock(threads) } | ||
fun List<ResultWithClock>.withEmptyClock() = map { it.result.withEmptyClock(it.clockOnStart.threads) } |
Oops, something went wrong.