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

🙋‍♂️question #212

Open
ZowieTao opened this issue Oct 14, 2022 · 0 comments
Open

🙋‍♂️question #212

ZowieTao opened this issue Oct 14, 2022 · 0 comments

Comments

@ZowieTao
Copy link

When the time interval for pushing the wheel is less than 500ms, the task scheduled between two pushes cannot be accurately obtained. Is this a problem of terminal performance? Is it avoidable?

const wheel = new TimerWheel<any>();
wheel.schedule('400', 400 /* ms */);
wheel.schedule('500', 500 /* ms */);
wheel.schedule('600', 600 /* ms */);
wheel.schedule('700', 700 /* ms */);
wheel.schedule('800', 800 /* ms */);
wheel.schedule('900', 900 /* ms */);
let i = 1;
setInterval(() => {
  console.info(i * 300, wheel);
  i++;
  const expired = wheel.advance();
  for (const data of expired) {
    console.info(data);
  }
}, 300);
300;
600;
900;
1200;
data: 400;
data: 500;
data: 600;
data: 700;
data: 800;
data: 900;
data: 1000;
data: 1100;
data: 1200;
1500;
1800;
2100;
data: 1300;
2400;
2700;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant