SetTimer and Threads
#1

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.
Reply
#2

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;
}
Reply
#3

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

Thanks, just what I needed.
Reply


Forum Jump:


Users browsing this thread: 1 Guest(s)