I'm working on an update to my version checking library which will make using it more like a standard module by requiring it and calling functions on the returned table (instead of its current behavior, which is to be loaded into a thread and called, then check a channel for its result). I would like to maintain compatibility with the old usage, so I want the module to detect if it is being loaded in a thread other than the main thread and respond differently in that case.
My solution for now is by checking if love.graphics or love.window is defined, as those are only accessible on the main thread. However, someone who has disabled these inside their conf.lua file will negate this attempt to check.
Is there any definite way to check from Lua code if it is running in the main thread or another thread?
Detecting if a file is running in the main thread, or a different thread
Forum rules
Before you make a thread asking for help, read this.
Before you make a thread asking for help, read this.
- Guard13007
- Party member
- Posts: 132
- Joined: Sat Oct 25, 2014 3:42 am
- Location: Internet, USA
- Contact:
Re: Detecting if a file is running in the main thread, or a different thread
Code: Select all
local isthread = arg == nil
- Guard13007
- Party member
- Posts: 132
- Joined: Sat Oct 25, 2014 3:42 am
- Location: Internet, USA
- Contact:
Re: Detecting if a file is running in the main thread, or a different thread
Thank you very much! :D
Who is online
Users browsing this forum: Google [Bot] and 79 guests