SA-MP Forums Archive
SetTimer and Threads - Printable Version

+- SA-MP Forums Archive (https://sampforum.blast.hk)
+-- Forum: SA-MP Scripting and Plugins (https://sampforum.blast.hk/forumdisplay.php?fid=8)
+--- Forum: Scripting Help (https://sampforum.blast.hk/forumdisplay.php?fid=12)
+---- Forum: Help Archive (https://sampforum.blast.hk/forumdisplay.php?fid=89)
+---- Thread: SetTimer and Threads (/showthread.php?tid=272066)



SetTimer and Threads - RSX - 27.07.2011

Does anybody know, how relate these two? My basic idea is that functions called by SetTimer are executed on another thread, but I'm not 100% sure, because it maintains 25% const of my cpu if I spin it in while(1), code used in testing this :

forward test();
public test() {while(1){}}

main() {
SetTimer("test",10,0);
return ;
}

So if you do this, you can make infinite loop, while making a while (1) loop in main freezes both server and console. Also, I guess while(1) isn't thread safe, if anyone knows that, let me know this too.


AW: SetTimer and Threads - Tigerkiller - 27.07.2011

pawn Код:
forward test(); // On the top

//Ongamemodelinit:
//OnFilterscriptinit:
SetTimer("test",ms,false); // true = all the times running :)
//warn: change ms to you milliseconds

//at least

public test()  {
   //Your Code here
   }
   return 1;
}



Re: SetTimer and Threads - Macluawn - 27.07.2011

There's a plugin for using multiple threads in samp.


Re: SetTimer and Threads - RSX - 27.07.2011

Thanks, just what I needed.