MCPcopy Index your code
hub / github.com/questdb/questdb / SynchronizedJob

Class SynchronizedJob

core/src/main/java/io/questdb/mp/SynchronizedJob.java:30–54  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

28import org.jetbrains.annotations.NotNull;
29
30public abstract class SynchronizedJob implements Job {
31 private static final long LOCKED_OFFSET = Unsafe.getFieldOffset(SynchronizedJob.class, "locked");
32
33 @SuppressWarnings({"unused", "FieldCanBeLocal"})
34 private volatile int locked = 0;
35
36 @Override
37 public boolean run(int workerId, @NotNull RunStatus runStatus) {
38 if (Unsafe.cas(this, LOCKED_OFFSET, 0, 1)) {
39 try {
40 return runSerially();
41 } finally {
42 locked = 0;
43 }
44 }
45 return false;
46 }
47
48 @Override
49 public boolean run(int workerId) {
50 return run(workerId, Job.RUNNING_STATUS);
51 }
52
53 protected abstract boolean runSerially();
54}

Callers

nothing calls this directly

Calls 1

getFieldOffsetMethod · 0.95

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…