Is consuming messages allready threaded?

Is processing recieved messages in listeners allready threaded or should i spawn my own threads to consume the message so i don’t block the main thread of the server for too long ?

<cite>@ryukajiya said:</cite> Is processing recieved messages in listeners allready threaded or should i spawn my own threads to consume the message so i don't block the main thread of the server for too long ?

Pretty sure that it is in its own thread. If it wasn’t i’m pretty sure it would block the game loop in my game and it doesn’t.

Received messages are on their own thread… and your listener is guaranteed to be called only once at a time.

Separate listeners for separate message types may be executed simultaneously (it’s implementation specific) but a specific listener is locked when it’s handling a message so you can count on that.

Useful because a fully reentrant listener is a pain to write and has way less utility.

Ok, thanks. So when i have to run some extensive funtions it is better to put that in a thread so listener is not blocked, but anything that runs fast is better left in the listener thread.

Might be a good documentation enhancement if you put what pspeed wrote in the documentation for spidermonkey.

@ryukajiya said: Ok, thanks. So when i have to run some extensive funtions it is better to put that in a thread so listener is not blocked, but anything that runs fast is better left in the listener thread.

Yes, this is a good idea for all listeners in general for any architecture.

@ryukajiya said: Might be a good documentation enhancement if you put what pspeed wrote in the documentation for spidermonkey.

The threading thing is mentioned here: http://hub.jmonkeyengine.org/javadoc/com/jme3/network/MessageListener.html

…but it could probably mention the listener synchronization thing. It does mention that on the server hosted connection messages are delivered synchronously… though it doesn’t specifically call it that.

I meant this page: https://wiki.jmonkeyengine.org/legacy/doku.php/jme3:advanced:networking because the wiki documentation is the place i look up most things for examples and i can imagine a lot start there too :wink: