473,378 Members | 1,319 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to implement a timer for 48 hrs and about timestamping..

hi,

i am storing a random token and userid,clientdata etc on a STL map container with the unique token as the KEY and the structure containg userid,clientdata etc as the VALUE.

Now i want to delete a token-Structure pair every 2 days. How will i know a particular token has expired?

Can i add another value on to the structure containing a time stamp of when it was created? Then after every 2 days some timer will expire which will trigger a check on all the tokens one by one by comparing its time stamp with the current system time. If it is greater than say 48 hrs then delete it.

But i dont know which standard function to use(like time() ). Is there any library function which does timeout... or how to implement a 48 hrs timer. can any one please suggest how to go about implementing this.....

some pointers atleast ...i will do the digging and get back..
Oct 27 '06 #1
4 2112
Banfa
9,065 Expert Mod 8TB
you could use a time_t variable in the structure to record the time it was created as returned by time().

If the platform you are using doesn't timers then you will have to go into a loop and keep checking the current time (remembering not to block anything else the program does) against the token times. If available on your platform it would be a wise idea to put some sleep time into this loop.
Oct 27 '06 #2
thanku verymuch...

wat i plan to do is to include the time value in to the token value pair using the time() function..
now after every 48 hrs i can compare all the elements time value with the current time..
if difftime(
Oct 29 '06 #3
thanku verymuch...

wat i plan to do is to include the time value in to the token value pair using the time() function..
now after every 48 hrs i can compare all the elements time value with the current time using difftime function..

how to implement this check after 48 hrs..
now, this map container belongs to a parent process ok..
so i fork a child and put it on a sleep cycle of 48 hrs..then send a user defined signal which will be caught by the parent process. when this signal is caught it will call a function to do the checking of times...

while(1){
sleep(48*3600);
send signal now..............
}
Is this forking a child to do this a costly way in terms of cpu time..
or instead of this method is there any way of the child process accessing the parents data structures.. child is getting only the copy when i fork..
Oct 29 '06 #4
Banfa
9,065 Expert Mod 8TB
Sorry you need someone who knows UNIX and that aint me.
Oct 30 '06 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

0
by: Aaron Leung | last post by:
Hi everyone, I want to take a shot at implementing a simple framework for functional reactive programming in Python. (It will be loosely based on a paper I read about a system called FrTime for...
1
by: wukexin | last post by:
I write my own class Cfile, I want to know what about implement ctime().Who help me? My use function ctime, I sign it with $$$. my class Cfile: #------------------------ file.h...
13
by: Manuel Lopez | last post by:
I have a puzzling form timer problem that I didn't experience prior to Access 2003 (though I'm not sure access 2003 is to blame). Here's the situation: a computer has two access 2003 databases on...
4
by: Peter Oliphant | last post by:
I'd like to be able to destroy a Timer in it's own event handler. That is, within it's tick handler I'd like to delete the Timer itself (e.g., for one-shot timers). Is this possible? In general,...
7
by: Crirus | last post by:
I have a server and I need to implement a automate process that occur at a certain interval, based on current time. I need to "tick" at every 10 minutes or (another version) when time is 30 minutes...
5
by: Flack | last post by:
Hey guys, Here is what I am trying to achieve: I have a grid, and every once in a while the grid will receive a message to add a new row and highlight it (change the backcolor) for five...
5
by: cok | last post by:
Hi, All I am working on a project ,It need a syntax-color, line-number... JScript editor, I cann't found a free one on GOOGLE, So I want to implement myself, I need some tips about...
6
by: paresh | last post by:
Hi all, I need to set timer in C/linux like alram, such that i will get a timeout signal after specific timeout and my process remain executing as is it. I can use signal(SIGALRM, xyz) and then...
19
by: UG | last post by:
I just wanted to know whether any timer facility exists in C, as it is not mentioned in K&R 2, or in the ISO Draft. By timer function i mean that when we use standard input function like scanf() or...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.