Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lib,test: deprecate _linklist #3078

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
57 changes: 3 additions & 54 deletions lib/_linklist.js
@@ -1,57 +1,6 @@
'use strict';

function init(list) {
list._idleNext = list;
list._idlePrev = list;
}
exports.init = init;
const msg = require('internal/util').printDeprecationMessage;


// 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;
module.exports = require('internal/linkedlist');
msg('_linklist module is deprecated. Please use a userland alternative.');
57 changes: 57 additions & 0 deletions lib/internal/linkedlist.js
@@ -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;
2 changes: 1 addition & 1 deletion lib/timers.js
@@ -1,7 +1,7 @@
'use strict';

const Timer = process.binding('timer_wrap').Timer;
const L = require('_linklist');
const L = require('internal/linkedlist');
const assert = require('assert').ok;
const util = require('util');
const debug = util.debuglog('timer');
Expand Down
5 changes: 3 additions & 2 deletions node.gyp
Expand Up @@ -17,7 +17,6 @@
'src/node.js',
'lib/_debug_agent.js',
'lib/_debugger.js',
'lib/_linklist.js',
'lib/assert.js',
'lib/buffer.js',
'lib/child_process.js',
Expand All @@ -39,6 +38,7 @@
'lib/_http_outgoing.js',
'lib/_http_server.js',
'lib/https.js',
'lib/_linklist.js',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did this get moved for a reason?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The list of files in lib appeared to be in alphabetical order (ignoring leading _ chars) with _linklist appearing to be one of a small number of exceptions. (_debug* is another but I left those). So I moved it to the logical-seeming place in the list. Seemed like a good idea at the time, but happy to move it back if there is any objection to it whatsoever.

'lib/module.js',
'lib/net.js',
'lib/os.js',
Expand Down Expand Up @@ -70,9 +70,10 @@
'lib/zlib.js',
'lib/internal/child_process.js',
'lib/internal/freelist.js',
'lib/internal/linkedlist.js',
'lib/internal/module.js',
'lib/internal/socket_list.js',
'lib/internal/repl.js',
'lib/internal/socket_list.js',
'lib/internal/util.js',
'lib/internal/streams/lazy_transform.js',
],
Expand Down
11 changes: 8 additions & 3 deletions test/parallel/test-timers-linked-list.js
@@ -1,8 +1,13 @@
'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 A = { name: 'A' };
Expand Down