注册一亩三分地论坛,查看更多干货!
您需要 登录 才可以下载或查看附件。没有帐号?注册账号
x
這個職位是做 Software Engineer - Trading Systems
考了一題設計API,要寫個scheduler.
class Scheduler{
public:
void AddJob(int key, int jobID, int secondsToStartExecuting){
// add job
<key> who add the job
<jobID> what is the job ID
<secondsToStartExecuting> this job is going to execute at "curr_time + secondsToStartExecuting"
}
int getNextJob(int key){
// return the JobID
}
void cleanup(){
// clean up the job that is pass the excution time
}
private:
int getCurrentTimeInSeconds(); // to get current time, you can directly use it without implementing
}
Note:
// multiple jobID can be assigned to one key. Within one key, the jobID will be unique
// the same jobID can be assigned to different key (assign jobID 234 to key 1, assign jobID 234 to key 5)
// key, jobID, secondsToStartExecuting will all be positive numbers.
t>
兩種方法可能對於clean up 會有trade off, 但是還沒有細細討論 時間就結束了 orz
這個系統很複雜,不知道我這樣講夠不夠清楚。有問題的話找我討論吧
如果有更好的structure 設計idea 歡迎分享
另外覺得有幫助的話賞個大米吧
|