lua.wire.thread
thread = wire.thread(handle)
thread = wire.thread(name)
thread = wire.thread(opts)
Create or get a thread table. Threads are not GC'd they must be created and destroyed explicitly.
When called with a handle (number) we return a previously created thread with that handle.
When called with a name (string) we return a previously created thread with that name.
We will assert if no thread is found with that handle or name, so no need to check returns.
When called with opts (table) we do the following based on the contents.
opts.handle=nil
The handle to wrap or use in creation. If a valid handle we will simply wrap it with a thread table and return that new table.
opts.start=nil
Run this string as lua code in a new thread. Usually just a require and a call to a function in that module. eg "require('modname').funcname()"
opts.globals={}
Optional globals for the new thread. Will be serialized and become part of the start string. So binary data strings are not ideal but will work.
opts.preloadlibs=wire.preloadlibs
Must be a cfunction to be run in new thread. Use false to not preload any custom libs. When running under gamecake this is automatically filled in and makes all the internal modules available. If you want to use this module outside of gamecake ( possible but not overly tested ) then you may need to provide your own.
opts.header=...
opts.footer=...
internal setup so best not to change this. It is used by wire.prepare_start to wrap your start code string with helpful error handlers etc.