473,587 Members | 2,489 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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

9 New Member
hi,

i am storing a random token and userid,clientda ta etc on a STL map container with the unique token as the KEY and the structure containg userid,clientda ta 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 2131
Banfa
9,065 Recognized Expert Moderator Expert
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
rockkyy
9 New Member
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
rockkyy
9 New Member
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 Recognized Expert Moderator Expert
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
1311
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 DrScheme.) However, I'm not sure how to go about implementing certain components. One basic component will be an object representing the current...
1
574
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 #--------------------------- #include <io.h> #include <ctime> #include <string>
13
7464
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 it, a frontend and a backend. Case 1: If vba code on the frontend updates many rows (360,000) on the backend, a form's timer event (from the...
4
1798
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, can a class instance destroy itself via one of it's own methods?
7
1354
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 after exact hour like in 1:30, 2:30...etc -- Ceers, Crirus ------------------------------
5
2112
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 minutes. After the five minutes has passed, unhighlight it. The grid needs to highlight any rows that have arrived in the last five minutes. Here is...
5
1473
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 implement editor control, Can anyone give me some advice?
6
10232
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 alarm(some value in sec), there is a constraint in this as i can pass timeout only in seconds and i need in milli sec. Any idea how todo this.
19
40784
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 getch() or any other function, the interface stops to take input from user but what if user doesn't give input for hours, the program will still be...
0
8349
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
0
8221
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
0
6629
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
1
5719
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
5395
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert...
0
3845
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
1
2364
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1455
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
1192
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.