Multithreading can be used to pass delayed
tasks to other script
s by link messages
The practice of multithreading to eliminate script delays is a mildly dangerous one at best, and holds the potential to bring a server
to its knees, or outright crash it at its worst. Please, for the love of the hippos
, try to refrain from multithreading unless it is absolutely
necessary for a script to have no script delay. A multithreaded script can cause problems for dozens or even hundreds of user
s if done needlessly. Multithreading can cause unnecessary strain on sims
or other servers, and should be avoided when possible.
An example of multithreading would be having a script that would need to send an email
every time something occured. By using llMessageLinked
, another script in the same object
could be told to send the email instead, thereby sparing the main script from llEmail
's built-in 20-second delay.
Example added by MarcEisenberg:
This is the mailing system script. Only one of these scripts in the linked object hierarchy is necessary:
This is the script that tells the mailing system it needs to email. Include this at the top of any script that will send mail in a linked object hierarchy:
Then, messages are sent using this: MT_SendEmail("email@example.com", "Subject", "This is my message");
The message will be passed off to the mail-handling script.
IMPORTANT! Please note that this example uses the number field in the linked messages as an identifier
for the type of message. If there are scripts in a linked object that send messages in another way, this script's link handling will need to be modified to match (or there may be problems with miscommunications