30.12.2012, 18:22
I think I get what you mean by using a 1ms timer.
Easing the load by calling func3 afterwards so other stuff can be done:
Is that somewhat close to what you are trying to explain?
Obviously you'd have to be very careful with the flow/structure as the code could end up doing something with some variables that are affected in the delayed function meaning they aren't at their correct values when they are accessed. If you understand me (I last slept about 40 hours ago... brain probably doesn't want to do stuff atm)
pawn Code:
func1()
{
// Each of these functions takes 4ms to execute, meaning when 'func1' is called, it takes
func2();
// this function doesn't really need to be called exactly here, it just needs to be called pretty much at the same time as 'func1'
// Maybe you call func1 100 times and don't want to have to add 'func3' underneath every call.
func3();
func4();
}
someCallback()
{
func1(); // This function takes an overall of 12ms
}
pawn Code:
func1()
{
func2();
func4();
defer func3();
}
timer func3[1]() // call it after 1ms
{
// func3's stuff that takes 4ms
}
someCallback()
{
func1(); // This function now takes 8ms
// func3 is called some time afterwards, but the server has a chance to do some other stuff like sync etc.
}
Obviously you'd have to be very careful with the flow/structure as the code could end up doing something with some variables that are affected in the delayed function meaning they aren't at their correct values when they are accessed. If you understand me (I last slept about 40 hours ago... brain probably doesn't want to do stuff atm)