System Timer32

Kenny

Back for now.
Reaction score
202
>Also, the name "next" and "prev" could conflict with other stuff... <_< any ideas for that issue? Or is that unlikely.

That was my biggest concern as well... That is where operators come in handy, but I don't think giving them an absurd name is going to be all that good.

It is unlikely that they will ever be used, so maybe even a T32_next or T32_getNext() or something. :p That way, although they are there, they will not conflict with anything, and it isn't something that someone will just type. They will only be there for people who know about them and understand their usage.
 

Azlier

Old World Ghost
Reaction score
461
Just here to say that this is handy.

JASS:
method periodic takes nothing returns nothing
    set Size = Size - 0.05
    call SetUnitScale(Burrow, Size, 0, 0)
    if Size == 0 then
        set Size = 1
        call stopPeriodic()
    endif
endmethod
 

Troll-Brain

You can change this now in User CP.
Reaction score
85
I fail to make a test where it proofs that thing is more efficient than using X timers instead.
Maybe internally timers are already handle like that ?

It starts to lag not because one or the other method, but just because of the tested code itself.

Maybe my pc is to much performant for a such test.
I understand that the API is neater here than just TimerUtils, though.

Could someone provide me an example where T32 is more efficient than using TimerUtils with X timers, plz ?
 

kingkingyyk3

Visitor (Welcome to the Jungle, Baby!)
Reaction score
216
KT2 is better than TimerUtils in short period(see the benchies). T32 is more efficient than KT2.
 

Sickle

New Member
Reaction score
13
However, there are plenty of benchmarks in the KT2 thread. And since T32 is a hardcoded KT2 period, logically it is faster. But, alas, logic does not work with Blizzard.
 

Romek

Super Moderator
Reaction score
963
The speeds are the same, the core system is identical.
The only difference is the method of stopping the executions.
 

Jesus4Lyf

Good Idea™
Reaction score
397
That's not true, actually. Look carefully:
T32:
JASS:
function Periodic takes integer i returns boolean
    if condition then // if/then.
        return true
    endif
    return false
endfunction
private function PeriodicLoop takes nothing returns boolean
    local thistype this=thistype(0).next
    loop
        exitwhen this==0
        if this.periodic() then // another if/then.
            // This is some real magic.
            set this.prev.next=this.next
            set this.next.prev=this.prev
            // This will even work for the starting element.
            debug set this.prev=0
        endif
        set this=this.next
    endloop
    return false
endmethod

T32x:
JASS:
function Periodic takes integer i returns nothing
    if condition then
        call this.stopPeriodic()
    endif
endfunction
private function PeriodicLoop takes nothing returns boolean
    local thistype this=thistype(0).next
    loop
        exitwhen this==0
        call this.periodic() // no second if statement.
        set this=this.next
    endloop
    return false
endmethod

T32x should be faster. Faster again, if you used a .ticks value and switch to .endTick and use T32_Tick.

But I haven't benchmarked T32x yet.
 

Hatebreeder

So many apples
Reaction score
381
shouldn't this [ljass] call TimerStart(CreateTimer(),PERIOD,true,function OnExpire) [/ljass] leak?
 

Romek

Super Moderator
Reaction score
963
> That's not true, actually. Look carefully:
Yes, it's pretty much the same. :p
The stuff within the 'if' in the periodic loop has simply been moved to another function.
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
I got a problem with your system.

It seems that certain frequencies make the system go malfunctioning.
I have this one function for camera movement that runs every 0.02 seconds. Now if I set the value to 0.015 the function stops running after some time, I think especially when I used other spells that include KT.
I wondered what could possibly be the issue and added a debug msg each time the function runs. And yeah as I thought for the 0.015 frequency the function just doesn't run anymore after using other spells or whatever including KT.
And all I change is the goddamn frequency!
 

GoGo-Boy

You can change this now in User CP
Reaction score
40
Ahh crap you're right, ment to be in they Key Timers 2 thread. Sorry :/
 

Nexor

...
Reaction score
74
I'm working on a map that uses currently about 10-12 spells, and the 70% of it uses T32.
There are some problems with it, sometimes the debugmessages are displayed but I don't see any reason why it should be displayed.

Here's an example:

JASS:
private struct slow
    unit hero
    integer ticks
    integer stacks
    
    method periodic takes nothing returns boolean
        local unit u
        set .ticks = .ticks - 1
        if .ticks == 0 or .stacks == 0 then
            set .ticks = T32_FPS
            set .stacks = .stacks + 1
            call UnitRemoveAbility(.hero,BuffID)
            set u = CreateUnit(Player(PLAYER_NEUTRAL_PASSIVE),&#039;dumy&#039;,GetUnitX(.hero),GetUnitY(.hero),0)
            call UnitAddAbility(u,SlowID)
            call SetUnitAbilityLevel(u,SlowID,.stacks)
            call UnitApplyTimedLife(u,&#039;BTLF&#039;,1.)
            call IssueTargetOrder(u,&quot;slow&quot;,.hero)
            set u = null
        elseif .stacks == 9 then
            set u = null
            return true
        endif
        return false
    endmethod
    
    implement T32
endstruct



private function onCast takes unit u returns nothing
    local slow S =  slow.create()
    
    set S.hero = u
    set S.stacks = 0
    set S.ticks = T32_FPS
    
    call S.startPeriodic()
    
endfunction



I see that it has been updated, what should I do to make it work with T32x?
 
General chit-chat
Help Users
  • No one is chatting at the moment.

      The Helper Discord

      Staff online

      Members online

      Affiliates

      Hive Workshop NUON Dome World Editor Tutorials

      Network Sponsors

      Apex Steel Pipe - Buys and sells Steel Pipe.
      Top