Do LUA addons execute in Wow's main thread? menu

User Tag List

Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Do LUA addons execute in Wow's main thread?

    Question in topic...
    Got some strange things going on which look as threading issues...

    Do LUA addons execute in Wow's main thread?
  2. #2
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Are you seriously asking this? No.. really.... seriously?

  3. #3
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    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.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  4. #4
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  5. #5
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @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...

  6. #6
    FenixTX2's Avatar Active Member
    Reputation
    22
    Join Date
    Mar 2009
    Posts
    125
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @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.

  7. #7
    MaiN's Avatar Elite User
    Reputation
    335
    Join Date
    Sep 2006
    Posts
    1,047
    Thanks G/R
    0/10
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by FenixTX2 View Post
    @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.
    Last edited by MaiN; 10-12-2009 at 07:31 AM.
    [16:15:41] Cypher: caus the CPU is a dick
    [16:16:07] kynox: CPU is mad
    [16:16:15] Cypher: CPU is all like
    [16:16:16] Cypher: whatever, i do what i want

  8. #8
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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.

  9. #9
    suicidity's Avatar Contributor
    Reputation
    207
    Join Date
    Oct 2006
    Posts
    1,439
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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. #10
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    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...

  11. #11
    flo8464's Avatar Active Member
    Reputation
    30
    Join Date
    Apr 2009
    Posts
    434
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Another reason it has to be executed by WoWs mainthread is that all relevant game-information is stored in the mainthreads TLS.

  12. #12
    Robske's Avatar Contributor
    Reputation
    305
    Join Date
    May 2007
    Posts
    1,062
    Thanks G/R
    3/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by ggg898 View Post
    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...
    "Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live." - Martin Golding
    "I cried a little earlier when I had to poop" - Sku

  13. #13
    Cypher's Avatar Kynox's Sister's Pimp
    Reputation
    1356
    Join Date
    Apr 2006
    Posts
    5,368
    Thanks G/R
    0/4
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by flo8464 View Post
    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.


    Originally Posted by suicidity View Post
    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.

  14. #14
    ggg898's Avatar Member
    Reputation
    10
    Join Date
    Jan 2009
    Posts
    39
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    @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.

  15. #15
    monko's Avatar Member
    Reputation
    1
    Join Date
    Jan 2020
    Posts
    1
    Thanks G/R
    0/0
    Trade Feedback
    0 (0%)
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Originally Posted by Cypher View Post
    Are you seriously asking this? No.. really.... seriously?
    Just stumbled upon this thread from Google. Just wanted to let you know you look like a massive dickhead

Page 1 of 2 12 LastLast

Similar Threads

  1. [How-To] how to obfuscate lua addons for wow ?
    By wowmacro in forum Programming
    Replies: 9
    Last Post: 09-21-2014, 12:12 AM
  2. Executing injected code on main thread
    By mozartmclaus in forum Diablo 3 Memory Editing
    Replies: 0
    Last Post: 05-23-2012, 03:04 PM
  3. Replies: 10
    Last Post: 02-13-2011, 01:21 AM
  4. LUA-Addons
    By RiseAndShine in forum WoW Memory Editing
    Replies: 0
    Last Post: 02-02-2009, 06:08 PM
All times are GMT -5. The time now is 11:22 PM. Powered by vBulletin® Version 4.2.3
Copyright © 2024 vBulletin Solutions, Inc. All rights reserved. User Alert System provided by Advanced User Tagging (Pro) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
Digital Point modules: Sphinx-based search