Avoid errors
This commit is contained in:
parent
2f3cea9d5b
commit
bcd99f4727
@ -280,7 +280,9 @@ public class LLLocalLuceneIndex implements LLLuceneIndex {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
scheduledTasksLifecycle.startScheduledTask();
|
if (!scheduledTasksLifecycle.tryStartScheduledTask()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
try {
|
try {
|
||||||
if (scheduledTasksLifecycle.isCancelled() || cancelled) return;
|
if (scheduledTasksLifecycle.isCancelled() || cancelled) return;
|
||||||
task.run();
|
task.run();
|
||||||
|
@ -27,6 +27,19 @@ public class ScheduledTaskLifecycle {
|
|||||||
this.lock.readLock();
|
this.lock.readLock();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Mark this task as running.
|
||||||
|
* After calling this method, please call {@method endScheduledTask} inside a finally block!
|
||||||
|
* @return false if failed
|
||||||
|
*/
|
||||||
|
public boolean tryStartScheduledTask() {
|
||||||
|
if (cancelled) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
this.lock.readLock();
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Mark this task as ended. Must be called after {@method startScheduledTask}
|
* Mark this task as ended. Must be called after {@method startScheduledTask}
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user