Comparing version 2.3.8 to 2.3.9
{ | ||
"name": "lmdb", | ||
"author": "Kris Zyp", | ||
"version": "2.3.8", | ||
"version": "2.3.9", | ||
"description": "Simple, efficient, scalable, high-performance LMDB interface", | ||
@@ -59,3 +59,4 @@ "license": "MIT", | ||
"prebuildify": "prebuildify --target 16.14.2", | ||
"prepublishOnly": "cd prebuilds/win32-x64 && npm publish --otp %OTP% && cd ../darwin-x64 && npm publish --otp %OTP% && cd ../darwin-arm64 && npm publish --otp %OTP% && cd ../linux-x64 && npm publish --otp %OTP% && cd ../linux-arm64 && npm publish --otp %OTP% && cd ../linux-arm && npm publish --otp %OTP% && cd ../..", | ||
"prepare": "rollup -c", | ||
"full-publish": "cd prebuilds/win32-x64 && npm publish --otp %OTP% && cd ../darwin-x64 && npm publish --otp %OTP% && cd ../darwin-arm64 && npm publish --otp %OTP% && cd ../linux-x64 && npm publish --otp %OTP% && cd ../linux-arm64 && npm publish --otp %OTP% && cd ../linux-arm && npm publish --otp %OTP% && cd ../.. && npm publish", | ||
"recompile": "node-gyp clean && node-gyp configure && node-gyp build", | ||
@@ -104,2 +105,2 @@ "test": "mocha test/**.test.js --recursive && npm run test:types", | ||
} | ||
} | ||
} |
53
write.js
@@ -66,3 +66,3 @@ import { getAddress, native } from './native.js'; | ||
var lastWritePromise; | ||
var writeBatchStart, outstandingBatchCount; | ||
var writeBatchStart, outstandingBatchCount, lastSyncTxnFlush, lastFlushTimeout, lastFlushCallback; | ||
txnStartThreshold = txnStartThreshold || 5; | ||
@@ -362,4 +362,6 @@ batchStartThreshold = batchStartThreshold || 1000; | ||
case 0: | ||
if (resolvers.length > 0) | ||
scheduleFlush(resolvers, Math.min((Date.now() - start << 1) + 1, maxFlushDelay)) | ||
if (resolvers.length > 0) { | ||
let delay = Date.now() - start | ||
scheduleFlush(resolvers, Math.min((flushPromise && flushPromise.hasCallbacks ? delay >> 1 : delay) + 1, maxFlushDelay)) | ||
} | ||
case 1: | ||
@@ -385,15 +387,24 @@ break; | ||
committedFlushResolvers = resolvers | ||
setTimeout(() => lastSync.then(() => { | ||
let resolvers = committedFlushResolvers || [] | ||
committedFlushResolvers = null | ||
lastSync = new Promise((resolve) => { | ||
env.sync(() => { | ||
for (let i = 0; i < resolvers.length; i++) | ||
resolvers[i](); | ||
resolve(); | ||
lastFlushTimeout = setTimeout(lastFlushCallback = () => { | ||
lastFlushTimeout = null; | ||
lastSync.then(() => { | ||
let resolvers = committedFlushResolvers || []; | ||
committedFlushResolvers = null; | ||
lastSync = new Promise((resolve) => { | ||
env.sync(() => { | ||
for (let i = 0; i < resolvers.length; i++) | ||
resolvers[i](); | ||
resolve(); | ||
}); | ||
}); | ||
}); | ||
}), delay || 0); | ||
}, delay || 0); | ||
} | ||
} | ||
function expediteFlush() { | ||
if (lastFlushTimeout) { | ||
clearTimeout(lastFlushTimeout); | ||
lastFlushCallback(); | ||
} | ||
} | ||
@@ -784,3 +795,3 @@ function queueCommitResolution(resolution) { | ||
if ((flags & 0x10000) && overlappingSync) // if it is no-sync in overlapping-sync mode, need to schedule flush for it to be marked as persisted | ||
scheduleFlush([]) | ||
lastSyncTxnFlush = new Promise(resolve => scheduleFlush([resolve])) | ||
} | ||
@@ -820,12 +831,18 @@ return result; | ||
if (flushPromise) | ||
return flushPromise.then(onfulfilled, onrejected); | ||
return committed.then(onfulfilled, onrejected); | ||
flushPromise.hasCallbacks = true | ||
return Promise.all([flushPromise || committed, lastSyncTxnFlush]).then(onfulfilled, onrejected); | ||
} | ||
}, | ||
_endWrites(resolvedPromise) { | ||
_endWrites(resolvedPromise, resolvedSyncPromise) { | ||
this.put = this.remove = this.del = this.batch = this.removeSync = this.putSync = this.transactionAsync = this.drop = this.clearAsync = () => { throw new Error('Database is closed') }; | ||
// wait for all txns to finish, checking again after the current txn is done | ||
let finalPromise = flushPromise || commitPromise || lastWritePromise; | ||
if (finalPromise && resolvedPromise != finalPromise) { | ||
return finalPromise.then(() => this._endWrites(finalPromise), () => this._endWrites(finalPromise)); | ||
if (flushPromise) | ||
flushPromise.hasCallbacks = true | ||
if (lastFlushTimeout) | ||
expediteFlush(); | ||
let finalSyncPromise = lastSyncTxnFlush; | ||
if (finalPromise && resolvedPromise != finalPromise || | ||
finalSyncPromise && resolvedSyncPromise != finalSyncPromise) { | ||
return Promise.all([finalPromise, finalSyncPromise]).then(() => this._endWrites(finalPromise, finalSyncPromise), () => this._endWrites(finalPromise, finalSyncPromise)); | ||
} | ||
@@ -832,0 +849,0 @@ Object.defineProperty(env, 'sync', { value: null }); |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
2314090
5388