| | WoW Memory Editing WoW Memory Editing for learning purposes only.
This section is more advanced than others on MMOwned Read the section specific rules, infractions will be given out if u break them!That is including the expectations! - If you don't meet them then don't post |  | 
10-12-2009
| | Corporal | | | Join Date: Jan 2009
Posts: 33
Reputation: 10 Level up: 87%, 52 Points needed | | | | Do LUA addons execute in Wow's main thread? Question in topic...
Got some strange things going on which look as threading issues... | Donate to remove ads, get your "DONATOR title, and get access to the MMOwned community's elite Shoutbawx. 
10-12-2009
|  | Kynox's sister's pimp Legendary User | | | Join Date: Apr 2006 Location: ntdll.dll
Posts: 4,185
Nominated 63 Times in 4 Posts  TOTM/W Award(s): 1 Reputation: 1085 Points: 55,512, Level: 35 | Level up: 14%, 3,188 Points needed |     | | | Are you seriously asking this? No.. really.... seriously? | 
10-12-2009
| | Contributor | | | Join Date: Sep 2006 Location: Jaedenar O.o
Posts: 569
Reputation: 162 Level up: 58%, 336 Points needed |     | | Quote:
Originally Posted by Cypher Are you seriously asking this? No.. really.... seriously? | What's so weird about this question?
AFAIK macros and text gets executed in the main thread.
Try typing this ingame: Code: /run for i=0,10000000 do for t=0,1000000 do end end
That will freeze WoW for a really long time - but why would Blizzard allow addons to freeze WoW's main thread?
@OP: I believe they do. Apoc posted a thread about hooking the OnUpdate script event for addons, which is basicly like an EndScene hook - it should be called from the main thread.
__________________ http://www.main-dev.com/
I was here. ~Dragon[Sky] I was here too. ~Kuiren | 
10-12-2009
| | Corporal | | | Join Date: Jan 2009
Posts: 33
Reputation: 10 Level up: 87%, 52 Points needed | | | | I dont realize it is such a stupid question.
I dont know if LUA parsers are threaded, if all LUA addons are executed side by side or one at a time, stuff like that ...
I would say without knowing anything about it, that that the main thread probably fires the frame update event syncronously, but i dont know for sure, hence asking. | 
10-12-2009
| | Corporal | | | Join Date: Jan 2009
Posts: 33
Reputation: 10 Level up: 87%, 52 Points needed | | | | @Main, thanks i have looked but i didnt find that info. I tried to do stuff like that. Call a custom lua command from an addon instead of endscene hook (or actually both during development) but some strange things happened, thats why I Just wanted to make sure the the Addon was executing in the main thread... | 
10-12-2009
|  | Master Sergeant | | | Join Date: Mar 2009 Location: /
Posts: 84
Reputation: 15 Level up: 50%, 250 Points needed |   | | | @MaiN: It makes sense for for loops to pause the main thread until completion, otherwise people could use them as a crude timing method for macro based bots. | 
10-12-2009
| | Contributor | | | Join Date: Sep 2006 Location: Jaedenar O.o
Posts: 569
Reputation: 162 Level up: 58%, 336 Points needed |     | | Quote:
Originally Posted by FenixTX2 @MaiN: It makes sense for for loops to pause the main thread until completion, otherwise people could use them as a crude timing method for macro based bots. | That's true, but not really. It's still easily done by using OnUpdate.
__________________ http://www.main-dev.com/
I was here. ~Dragon[Sky] I was here too. ~Kuiren
Last edited by MaiN; 10-12-2009 at 09:31 AM.
| 
10-12-2009
| | Corporal | | | Join Date: Jan 2009
Posts: 33
Reputation: 10 Level up: 87%, 52 Points needed | | | | Think I can answer this one myself... and the answer is... No...
(Or maybe No... really... seriously... ;P)
GetCurrentThreadId returns different ids when called from Lua addon and from endscene hook. | 
10-12-2009
|  | Contributor | | | Join Date: Oct 2006 Location: In your attic.
Posts: 1,205
Reputation: 148 Level up: 25%, 831 Points needed |     | | | Lua is not Multi-Threaded capable, at least not in it's current incarnation. Lua must be called from the Main Thread of the game. | 
10-12-2009
| | Corporal | | | Join Date: Jan 2009
Posts: 33
Reputation: 10 Level up: 87%, 52 Points needed | | | | So... How come I got the result I got from my little test?
1. Reg you Lua function which just call GetCurrentThreadId(), call that func from Lua addon
2. Call GetCurrentTreadId() from endscene
3. Compare, at least I get diffent ids... | 
10-12-2009
|  | Knight | | | Join Date: Apr 2009
Posts: 223
Reputation: 11 Level up: 10%, 454 Points needed |   | | | Another reason it has to be executed by WoWs mainthread is that all relevant game-information is stored in the mainthreads TLS. | 
10-12-2009
|  | Contributor | | | Join Date: May 2007 Location: Dragon Shores
Posts: 690
Reputation: 167 Level up: 28%, 651 Points needed |     | | Quote:
Originally Posted by ggg898 So... How come I got the result I got from my little test?
1. Reg you Lua function which just call GetCurrentThreadId(), call that func from Lua addon
2. Call GetCurrentTreadId() from endscene
3. Compare, at least I get diffent ids... |
__________________ “Saying that Java is nice because it works on all OSes is like saying that anal sex is nice because it works on all genders.”
“If Java had true garbage collection, most programs would delete themselves upon execution.” | 
10-12-2009
|  | Kynox's sister's pimp Legendary User | | | Join Date: Apr 2006 Location: ntdll.dll
Posts: 4,185
Nominated 63 Times in 4 Posts  TOTM/W Award(s): 1 Reputation: 1085 Points: 55,512, Level: 35 | Level up: 14%, 3,188 Points needed |     | | Quote:
Originally Posted by flo8464 Another reason it has to be executed by WoWs mainthread is that all relevant game-information is stored in the mainthreads TLS. | Ladies an gentleman we have a winner!
1. The object manager is thread-local and only available in the main thread.
2. Lots of the Lua callbacks rely on the object manager.
3. Ergo, Lua must be executed in the main thread. Quote:
Originally Posted by suicidity Lua is not Multi-Threaded capable, at least not in it's current incarnation. Lua must be called from the Main Thread of the game. | This too. | 
10-13-2009
| | Corporal | | | Join Date: Jan 2009
Posts: 33
Reputation: 10 Level up: 87%, 52 Points needed | | | | @robske, Ok thanks, must be something strange that messed up my test.
And thanks to all other too taking time. Thought about the TLS but was confused by my test, which must have been f****d up. |  |
Posting Rules
| You may not post new threads You may not post replies You may not post attachments You may not edit your posts HTML code is Off | | | All times are GMT -4. The time now is 06:33 AM. |