我想知道这是否是在Node.js中执行递归 class OrderManager {
int m_totalOrderSize; //needs to store the sum of all order sizes
std::vector<Order> Orders; //the array with the size variable.
}
class Order {
int size; //this size variable is updated in many ways in this class.
/*
This is one of the function that updates size.
How do I make sure whenever size gets updated here, the
OrderManager.m_totalOrderSize also gets updated accordingly.
*/
UpdateSize();
ResetSize();
}
的正确方法?
setTimeout
我正在尝试在Node.js中实现重新连接机制。但是我不确定这条线是否会在JavaScript中产生副作用? module.exports = {
connect: function(callback) {
amqp.connect(config.queue.url, function(err, connection) {
if (err) {
console.error("[AMQP]", err.message);
return setTimeout(module.exports.connect, 1000); // keep reconnecting
}
});
}
}
答案 0 :(得分:0)
It should work fine but i think you should improve your code to allow notification of the caller of the connection attempt (even if you perform reconnection).