Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -216,7 +216,7 @@ void rollback() throws SailException {
if (tripleStoreException != null) {
throw wrapTripleStoreException();
} else {
Thread.yield();
Thread.onSpinWait();
}
}
} else {
Expand Down Expand Up @@ -478,7 +478,7 @@ public void flush() throws SailException {
if (tripleStoreException != null) {
throw wrapTripleStoreException();
} else {
Thread.yield();
Thread.onSpinWait();
}
}
}
Expand All @@ -491,7 +491,7 @@ public void flush() throws SailException {
if (tripleStoreException != null) {
throw wrapTripleStoreException();
} else {
Thread.yield();
Thread.onSpinWait();
}
}
}
Expand Down Expand Up @@ -676,30 +676,29 @@ private void startTransaction(boolean preferThreading) throws SailException {
} else if (Thread.interrupted()) {
throw new InterruptedException();
} else {
Thread.yield();
Thread.onSpinWait();
}
}
}

// keep thread running for at least 2ms to lock-free wait for the next
// keep thread running for a short while to lock-free wait for the next
// transaction
long start = 0;
while (running.get() && !nextTransactionAsync) {
if (start == 0) {
// System.currentTimeMillis() is expensive, so only call it when we
// are sure we need to wait
start = System.currentTimeMillis();
// only call System.nanoTime() if we need to wait
start = System.nanoTime();
}

if (System.currentTimeMillis() - start > 2) {
if (System.nanoTime() - start > 100000) {
synchronized (storeTxnStarted) {
if (!nextTransactionAsync) {
running.set(false);
return;
}
}
} else {
Thread.yield();
Thread.onSpinWait();
}
}
}
Expand Down Expand Up @@ -846,15 +845,15 @@ public void execute() throws Exception {
if (tripleStoreException != null) {
throw wrapTripleStoreException();
} else {
Thread.yield();
Thread.onSpinWait();
}
}

while (!removeOp.finished) {
if (tripleStoreException != null) {
throw wrapTripleStoreException();
} else {
Thread.yield();
Thread.onSpinWait();
}
}
return removeCount[0];
Expand Down Expand Up @@ -932,7 +931,7 @@ public CloseableIteration<? extends Statement> getStatements(Resource subj, IRI
try {
logger.warn("Failed to get statements, retrying", e);
// try once more before giving up
Thread.yield();
Thread.onSpinWait();
return createStatementIterator(txn, subj, pred, obj, explicit, contexts);
} catch (IOException e2) {
throw new SailException("Unable to get statements", e);
Expand Down
Loading
Loading