提交 b4616c5e authored 作者: noelgrandin's avatar noelgrandin

make the code read easier

上级 b69287cb
...@@ -112,30 +112,33 @@ public class Sequence extends SchemaObjectBase { ...@@ -112,30 +112,33 @@ public class Sequence extends SchemaObjectBase {
* @param session the session * @param session the session
*/ */
public synchronized void flush(Session session) { public synchronized void flush(Session session) {
Session sysSession = database.getSystemSession();
if (session == null || !database.isSysTableLocked()) { if (session == null || !database.isSysTableLocked()) {
// this session may not lock the sys table (except if it already has locked it) // this session may not lock the sys table (except if it already has locked it)
// because it must be committed immediately // because it must be committed immediately
// otherwise other threads can not access the sys table. // otherwise other threads can not access the sys table.
session = sysSession; Session sysSession = database.getSystemSession();
} synchronized (sysSession) {
synchronized (session) { flushInternal(sysSession);
// just for this case, use the value with the margin for the script
long realValue = value;
try {
value = valueWithMargin;
database.update(session, this);
} finally {
value = realValue;
}
if (session == sysSession) {
// if the system session is used,
// the transaction must be committed immediately
sysSession.commit(false); sysSession.commit(false);
} }
} else {
synchronized (session) {
flushInternal(session);
}
} }
} }
private void flushInternal(Session session) {
// just for this case, use the value with the margin for the script
long realValue = value;
try {
value = valueWithMargin;
database.update(session, this);
} finally {
value = realValue;
}
}
/** /**
* Flush the current value to disk and close this object. * Flush the current value to disk and close this object.
*/ */
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论