Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 508149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T06:52:39+00:00 2026-05-13T06:52:39+00:00

Let’s say there is an imaginary operating system… There is a function in it

  • 0

Let’s say there is an imaginary operating system…

There is a function in it called settime that gets a pointer to function and a timestamp.

The catch is that every time the function is called it runs over the last call (so only the new function being provided as parameter will be called).

I want to expose a new function to my users called settime2, which will allow users to call it, and time a function without destroying the previous calls.

In the settime2 implementation I can call settime. and getcurrenttime. and even call settime with settime or settime2 as the function pointer argument.

Any advice?

thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T06:52:39+00:00Added an answer on May 13, 2026 at 6:52 am

    Working under the assumption that the function that gets called is called at a specific time…

    What settime2 needs to do is keep a linked list of function pointers and timestamp values.
    Insert a new function/timestamp value into the list in sorted order: earliest first.

    Use settime to set up a generic handler function and set the timeout to the earliest time required (the head of the timeout list).

    When the generic handler is called, remove the head of the list and call its function.
    Do this repeatedly if the head of the list has the same timestamp.

    If the list is not empty, call settime again with the timestamp at the head of the list.

    If the timestamp is really a duration (e.g. 10msec), do almost the same thing but have the saved durations be the sum of the all the previous durations and a delta to form the last duration.

    For example, three calls, with (f,15), (g,7), (h, 7), and (i,20) would make the list

    head -> (g,7) -> (h,0) -> (f, 8) -> (i,5)
    

    The first settime would be at 7 and g and h would get called. the next settime would be 8 after that (a total of 15) and f called, and finally after 5 more (at 20) i would be called.

    Be careful to handle the list changing when it is active. 😉

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 384k
  • Answers 384k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Look at WriteableBitmap.Render. It takes a UIElement as argument which… May 14, 2026 at 11:07 pm
  • Editorial Team
    Editorial Team added an answer Before you call slideToggle(), use .stop(true), this ends the current… May 14, 2026 at 11:07 pm
  • Editorial Team
    Editorial Team added an answer I found 2 myself: VSTS Scrum Process Template eScrum But… May 14, 2026 at 11:07 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.