Skip to content
Merged
Changes from 1 commit
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
31 changes: 19 additions & 12 deletions src/foam/util/NUIDGenerator.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ foam.CLASS({
}

AtomicLong seqNo_ = new AtomicLong();
AtomicBoolean initMaxSeqNo_ = new AtomicBoolean(false);
volatile AtomicBoolean initMaxSeqNo_ = new AtomicBoolean(false);
`,

properties: [
Expand Down Expand Up @@ -87,18 +87,25 @@ foam.CLASS({
{
name: 'initMaxSeqNo',
javaCode: `
if ( ! initMaxSeqNo_.getAndSet(true) ) {
Logger logger = Loggers.logger(getX(), this);
logger.info(getSalt(), "max", "find");
getDao().select(new AbstractSink() {
@Override
public void put(Object obj, Detachable sub) {
var id = (long) getPropertyInfo().get(obj);
maybeUpdateSeqNo(id);
}
});
Loggers.logger(getX(), this).info(getSalt(), "max", "found", seqNo_.get());
if ( ! initMaxSeqNo_.get() ) {
synchronized ( initMaxSeqNo_ ) {
if ( ! initMaxSeqNo_.get() ) {
Logger logger = Loggers.logger(getX(), this);
logger.info(getSalt(), "max", "find");
getDao().select(new AbstractSink() {
@Override
public void put(Object obj, Detachable sub) {
var id = (long) getPropertyInfo().get(obj);
maybeUpdateSeqNo(id);
}
public void eof() {
initMaxSeqNo_.getAndSet(true);
}
});
Loggers.logger(getX(), this).info(getSalt(), "max", "found", seqNo_.get());
}
}
}
`
},
{
Expand Down