Author Topic: Threading  (Read 836 times)

0 Members and 1 Guest are viewing this topic.

Offline yexxle

  • Major(1)
  • Posts: 22
Threading
« on: June 15, 2007, 03:04:52 pm »
Are clients' demands of our scripted functions/procedures handled concurrently by the server in multiple threads, or in sequence in one process? For example, if two kills and a spawn happen "at the same time", do the two onPlayerKill's and one onPlayerRespawn get executed together, or will they each be called one at a time in turn?

Most definitely need to know the answer to this before I continue what I'm working on. Much of my project's work depends on knowing the answer to this. One example I've run into so far is with sockets. I'd rather work with one global socket vs. creating a new socket for each connected client. But if the server process is threaded, I won't risk it.

Offline chrisgbk

  • Moderator
  • Veteran
  • *****
  • Posts: 1739
Re: Threading
« Reply #1 on: June 15, 2007, 03:21:20 pm »
I believe they may be handled in threads implicitly by virtue of using the UDP server class, but I'm not sure on that offhand; easy way to find out would be with a script; make a text trigger that says something via console, and make a fake long loop (don't use sleep) to delay time, then say something else that also is a text trigger, without the loop. If you see the second before the first, it's threaded, otherwise the server will pause while it does the loop, then display the messages in order.

Offline yexxle

  • Major(1)
  • Posts: 22
Re: Threading
« Reply #2 on: June 15, 2007, 03:54:51 pm »
Thanks for the suggestion. Thanks too for using the word "sleep", because I realized I could just use that. Created a trigger that sleeps for 60 secs, then tried a "/kill" during the sleep. Death doesn't come until the sleep is done. Then I realized that only proves it's one thread per client, not necessarily one process for all clients. So I ran two clients (I didn't know if you *could* run two clients on the same machine, but you can), started the sleep with the first guy, then did a "/kill" with the other guy. The kill doesn't come, and both clients wind up getting booted with "[user] could not respond" appearing on the soldatserver console.

This *seems* to confirm that it's only one process sans threads. Unless it's one thread per ip (which doesn't make much sense), or threads that wait in turn (possible, but acceptable for my work).

Date Posted: June 15, 2007, 04:51:17 PM
P.S.: Someone should really put together a list of functions and procedures we have access to and that are not being ripped out of the server in the near future. It's stuff like Sleep(), ThreadFunc(), SetArrayLength(), etc. that aren't documented to be available but just happen to be there if you somehow figure out they exist.

Offline urraka

  • Soldat Developer
  • Flagrunner
  • ******
  • Posts: 703
Re: Threading
« Reply #3 on: June 15, 2007, 05:08:01 pm »
I think the functions like ThreadFunc isn't documented because it tends to cause bugs.

Also, the only event that is threaded is OnPlayerSpeak i think. Or at least that's what the documentation says.
urraka

Offline DorkeyDear

  • Veteran
  • *****
  • Posts: 1507
  • I also go by Curt or menturi
Re: Threading
« Reply #4 on: June 16, 2007, 09:03:35 pm »
I'm actually making my own text document (i was bored once) with the events and functions and stuff, including some of the unused, and soon-to-comes and old ones (marked as their latest version allowed in)... eh, i really wonder if im going to work on that some more. Maybe sometime in the future i'll release it... if i ever come around working on it some more.