Skip to content

Instantly share code, notes, and snippets.

@ndkoval
ndkoval / gist:66ba2c127534c584197a85e6570a140f
Created October 23, 2018 15:03
An example of generated code for suspended functions in Lin-Check
fun thread1() {
val results = arrayOfNulls<Any?>(2) { NO_RESULT }
val suspended = Array(2) { false }
val ch = Channel<Int>()
// send(5)
// receive()
val startSendBlock: suspend () -> Unit = { ch.send(5) }
== Basic synchronization primitives ==
(all of them should support cancellation)
Mutex:
isLocked: Boolean
tryLock(owner = null): Boolean
suspend lock(owner = null)
unlock(owner = null)
holdsLock(owner): Boolean
public static void main(String[] args) {
// see https://github.com/Devexperts/lin-check
LinChecker.check(new LinearizabilityTest());
}
@CTest(iterations = 1000, actorsPerThread = {"3:5", "3:5"})
public static class LinearizabilityTest {
private Queue<Integer> q;
@Reset
import os
import math
def printAsBigHeader(s):
print '=' * len(s)
print s
print '=' * len(s)
return
public class CopyUtils {
public static <T> T deepCopy(T origObj) {
Cloner cloner = new Cloner();
try {
return cloner.clone(origObj);
} catch (InstantiationException e) {
throw new IllegalStateException(e);
}
}
import java.io.*;
import java.util.*;
public class Main {
public static void main(String[] args) {
InputStream inputStream = System.in;
OutputStream outputStream = System.out;
InputReader in = new InputReader(inputStream);
PrintWriter out = new PrintWriter(outputStream);