lib,test: deprecate _linklist
Deprecate _linklist and add test to confirm internal linklist and public _linklist are the same. PR-URL: https://github.com/nodejs/node/pull/3078 Reviewed-By: Сковорода Никита Андреевич <chalkerx@gmail.com> Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
This commit is contained in:
parent
01908d0a9a
commit
47befffc53
@ -1,57 +1,6 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
function init(list) {
|
const msg = require('internal/util').printDeprecationMessage;
|
||||||
list._idleNext = list;
|
|
||||||
list._idlePrev = list;
|
|
||||||
}
|
|
||||||
exports.init = init;
|
|
||||||
|
|
||||||
|
module.exports = require('internal/linkedlist');
|
||||||
// show the most idle item
|
msg('_linklist module is deprecated. Please use a userland alternative.');
|
||||||
function peek(list) {
|
|
||||||
if (list._idlePrev == list) return null;
|
|
||||||
return list._idlePrev;
|
|
||||||
}
|
|
||||||
exports.peek = peek;
|
|
||||||
|
|
||||||
|
|
||||||
// remove the most idle item from the list
|
|
||||||
function shift(list) {
|
|
||||||
var first = list._idlePrev;
|
|
||||||
remove(first);
|
|
||||||
return first;
|
|
||||||
}
|
|
||||||
exports.shift = shift;
|
|
||||||
|
|
||||||
|
|
||||||
// remove a item from its list
|
|
||||||
function remove(item) {
|
|
||||||
if (item._idleNext) {
|
|
||||||
item._idleNext._idlePrev = item._idlePrev;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (item._idlePrev) {
|
|
||||||
item._idlePrev._idleNext = item._idleNext;
|
|
||||||
}
|
|
||||||
|
|
||||||
item._idleNext = null;
|
|
||||||
item._idlePrev = null;
|
|
||||||
}
|
|
||||||
exports.remove = remove;
|
|
||||||
|
|
||||||
|
|
||||||
// remove a item from its list and place at the end.
|
|
||||||
function append(list, item) {
|
|
||||||
remove(item);
|
|
||||||
item._idleNext = list._idleNext;
|
|
||||||
list._idleNext._idlePrev = item;
|
|
||||||
item._idlePrev = list;
|
|
||||||
list._idleNext = item;
|
|
||||||
}
|
|
||||||
exports.append = append;
|
|
||||||
|
|
||||||
|
|
||||||
function isEmpty(list) {
|
|
||||||
return list._idleNext === list;
|
|
||||||
}
|
|
||||||
exports.isEmpty = isEmpty;
|
|
||||||
|
57
lib/internal/linkedlist.js
Normal file
57
lib/internal/linkedlist.js
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
'use strict';
|
||||||
|
|
||||||
|
function init(list) {
|
||||||
|
list._idleNext = list;
|
||||||
|
list._idlePrev = list;
|
||||||
|
}
|
||||||
|
exports.init = init;
|
||||||
|
|
||||||
|
|
||||||
|
// show the most idle item
|
||||||
|
function peek(list) {
|
||||||
|
if (list._idlePrev == list) return null;
|
||||||
|
return list._idlePrev;
|
||||||
|
}
|
||||||
|
exports.peek = peek;
|
||||||
|
|
||||||
|
|
||||||
|
// remove the most idle item from the list
|
||||||
|
function shift(list) {
|
||||||
|
var first = list._idlePrev;
|
||||||
|
remove(first);
|
||||||
|
return first;
|
||||||
|
}
|
||||||
|
exports.shift = shift;
|
||||||
|
|
||||||
|
|
||||||
|
// remove a item from its list
|
||||||
|
function remove(item) {
|
||||||
|
if (item._idleNext) {
|
||||||
|
item._idleNext._idlePrev = item._idlePrev;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (item._idlePrev) {
|
||||||
|
item._idlePrev._idleNext = item._idleNext;
|
||||||
|
}
|
||||||
|
|
||||||
|
item._idleNext = null;
|
||||||
|
item._idlePrev = null;
|
||||||
|
}
|
||||||
|
exports.remove = remove;
|
||||||
|
|
||||||
|
|
||||||
|
// remove a item from its list and place at the end.
|
||||||
|
function append(list, item) {
|
||||||
|
remove(item);
|
||||||
|
item._idleNext = list._idleNext;
|
||||||
|
list._idleNext._idlePrev = item;
|
||||||
|
item._idlePrev = list;
|
||||||
|
list._idleNext = item;
|
||||||
|
}
|
||||||
|
exports.append = append;
|
||||||
|
|
||||||
|
|
||||||
|
function isEmpty(list) {
|
||||||
|
return list._idleNext === list;
|
||||||
|
}
|
||||||
|
exports.isEmpty = isEmpty;
|
@ -1,7 +1,7 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
const Timer = process.binding('timer_wrap').Timer;
|
const Timer = process.binding('timer_wrap').Timer;
|
||||||
const L = require('_linklist');
|
const L = require('internal/linkedlist');
|
||||||
const assert = require('assert').ok;
|
const assert = require('assert').ok;
|
||||||
const util = require('util');
|
const util = require('util');
|
||||||
const debug = util.debuglog('timer');
|
const debug = util.debuglog('timer');
|
||||||
|
5
node.gyp
5
node.gyp
@ -17,7 +17,6 @@
|
|||||||
'src/node.js',
|
'src/node.js',
|
||||||
'lib/_debug_agent.js',
|
'lib/_debug_agent.js',
|
||||||
'lib/_debugger.js',
|
'lib/_debugger.js',
|
||||||
'lib/_linklist.js',
|
|
||||||
'lib/assert.js',
|
'lib/assert.js',
|
||||||
'lib/buffer.js',
|
'lib/buffer.js',
|
||||||
'lib/child_process.js',
|
'lib/child_process.js',
|
||||||
@ -39,6 +38,7 @@
|
|||||||
'lib/_http_outgoing.js',
|
'lib/_http_outgoing.js',
|
||||||
'lib/_http_server.js',
|
'lib/_http_server.js',
|
||||||
'lib/https.js',
|
'lib/https.js',
|
||||||
|
'lib/_linklist.js',
|
||||||
'lib/module.js',
|
'lib/module.js',
|
||||||
'lib/net.js',
|
'lib/net.js',
|
||||||
'lib/os.js',
|
'lib/os.js',
|
||||||
@ -70,9 +70,10 @@
|
|||||||
'lib/zlib.js',
|
'lib/zlib.js',
|
||||||
'lib/internal/child_process.js',
|
'lib/internal/child_process.js',
|
||||||
'lib/internal/freelist.js',
|
'lib/internal/freelist.js',
|
||||||
|
'lib/internal/linkedlist.js',
|
||||||
'lib/internal/module.js',
|
'lib/internal/module.js',
|
||||||
'lib/internal/socket_list.js',
|
|
||||||
'lib/internal/repl.js',
|
'lib/internal/repl.js',
|
||||||
|
'lib/internal/socket_list.js',
|
||||||
'lib/internal/util.js',
|
'lib/internal/util.js',
|
||||||
'lib/internal/streams/lazy_transform.js',
|
'lib/internal/streams/lazy_transform.js',
|
||||||
],
|
],
|
||||||
|
@ -1,8 +1,13 @@
|
|||||||
'use strict';
|
'use strict';
|
||||||
var common = require('../common');
|
|
||||||
var assert = require('assert');
|
|
||||||
var L = require('_linklist');
|
|
||||||
|
|
||||||
|
// Flags: --expose-internals
|
||||||
|
|
||||||
|
const common = require('../common');
|
||||||
|
const assert = require('assert');
|
||||||
|
const L = require('_linklist');
|
||||||
|
const internalL = require('internal/linkedlist');
|
||||||
|
|
||||||
|
assert.strictEqual(L, internalL);
|
||||||
|
|
||||||
var list = { name: 'list' };
|
var list = { name: 'list' };
|
||||||
var A = { name: 'A' };
|
var A = { name: 'A' };
|
||||||
|
Loading…
x
Reference in New Issue
Block a user