In my program, i have a function, example: bool open(string szString);
this function i have known it's fix address, example: 0x12345678
Because of my computer which has low capability, if this function is called 1000 times per second
it will be hanged, slow. So i want limit the number of function call down to 500 times per second.
how will i do with C/C++?
Thanks all.
A function is going to be called as many times as it's called. The only way to call it less often is to call it less often.
Functions calls typically aren't "optional". I mean you're calling this function because it does work that you need done, right? So if you don't call it... what else is your program doing? I assume it can't do other work because that other work probably relies on the open() call completing.
If your computer can't keep up with the amount of work that your program needs to do, the only thing you can really do is optimize your program to make it run faster. That is, remove unnecessary work and do things more efficiently.
I am surprised that your computer can't keep up with 1000 function calls a second... so this function either should be being called so often, or it's doing things very inefficiently.