• 🏆 Texturing Contest #33 is OPEN! Contestants must re-texture a SD unit model found in-game (Warcraft 3 Classic), recreating the unit into a peaceful NPC version. 🔗Click here to enter!
  • It's time for the first HD Modeling Contest of 2024. Join the theme discussion for Hive's HD Modeling Contest #6! Click here to post your idea!

[Snippet] Thread

Level 17
Joined
Apr 27, 2008
Messages
2,455
That won't work because a leaving player may/may not have run a selection event (possible early fire)

Also, the leaving player may be the last one to run the selection event, in which case the synced var is never updated.

My assumption is that the leaving player won't trigger the select event but trigger the player leave event.
If it trigger the player event then the code in the current version is fine.
 
Level 3
Joined
Nov 30, 2012
Messages
30
JASS:
method wait takes nothing returns nothing
            loop
                call TriggerSyncStart()
                call SelectUnit(threadSyncer, true)
                call SelectUnit(threadSyncer, false)
                exitwhen synced_p
                call TriggerSyncReady()
            endloop
        endmethod
or it may not exit loop
 
Level 3
Joined
Nov 30, 2012
Messages
30
Because you're using it wrong

It will break something like Network library

In fact,I use library"GameStart" ,and I found it loops Thread.wait and can't get to line "set gameStarted = true".I tried to change method wait,and it worked.
I suggest if Thread is right,GameStart may be wrong.
 
Level 3
Joined
Nov 30, 2012
Messages
30
Game Start is correct and it will wait until all players have finished loading the map.


And yes, I just looked.



The problem you speak of, of it never exiting... I've never run into that.

I test it again,and it still don't work before add the two line.
 
Last edited:
Level 23
Joined
Apr 16, 2012
Messages
4,041
just a question, why on earth you kept * * Alloc * hiveworkshop.com/forums/jass-resources-412/snippet-alloc-192348/
there? It is not used, so why having it, it may be confusing because people may think it is typo and will also use Alloc even tho it is not needed

edit: actually, there is implement Alloc in there, so Alloc should actually be required because it will not compile otherwise
 
Level 18
Joined
Jan 21, 2006
Messages
2,552
Nestharus:
  • Writes libraries of code and tests them for 40 hours, so that 1 person can use the code in a script for a map that 2 people will ever play.
  • Writes libraries named "Thread" that don't really give you any control over threads, other than one specific scenario that, as mentioned, 2 people have ever encountered.
  • Claims that he tests his code "hardcore" and there is no probability that it will not work.
  • Discourages people from testing his code (that has been hardcore tested) only to find an "issue" somewhere in the code.

What a joke.
 
Level 31
Joined
Jul 10, 2007
Messages
6,306
0 errors, this runs correctly >.>


Are you sure that you tested it in a synchronous thread? The thread must be synchronous.


This code works perfectly

JASS:
function BooBoo takes nothing returns nothing
    local Thread thread = Thread.create()
    
    if (GetLocalPlayer() == Player(0)) then
        call thread.sync()
    endif
    
    call thread.wait()
    
    call DisplayTimedTextToPlayer(GetLocalPlayer(),0,0,60,"hi")
endfunction

struct Tester extends array
    private static method onInit takes nothing returns nothing
        call ExecuteFunc("BooBoo")
    endmethod
endstruct

Not ganna fix something that's not broken, lol
 
Top