`
yangyi
  • 浏览: 115641 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

Predicted transactions

 
阅读更多

When you put something into a dynamic array, it won't grow by just 1 when reaching the limit.  This is important because changing size is an expensive operation.

 

For example if I have a job to execute, and the input data just keep coming and coming every now and then.

 

There could be 2 models for this: 

 

Solution #1: Keep a timeout for the job, extend the execution time by fixed time(such as 1s)  every time we received a new job. When timeout is reached, execute the job. 

When a new input come, and there's no existing job available, we simple create a new job

 

Solution #2: Keep a timeout for the tob, before execution, collect new inputs, before execution in the last second, mark it as silent period. If we have new input coming in the silent period, do not execute the job, request another spin of time as the timeout is defined.

 

0
0
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics