struct

Tryst::SDL::Track::StopSignal

Inherits Struct < Value < Object

How many times the audio thread has seen this track stop.

A counter rather than a flag so that a track which stops, is replayed and stops again between two dispatches reports both, instead of the second one being swallowed.

Exactly one writer - the audio thread, through increment - and exactly one reader, the main thread in deliver_stopped. That is what makes a plain aligned Int32 enough here without atomics: no two threads ever write it, so the worst case is the main thread reading a value one behind and delivering on the next dispatch.

A struct behind a pointer has VALUE semantics, so pointer.value .count += 1 would increment a copy and discard it. increment copies into a local, changes that, and writes the whole struct back, which is the one spelling that works.

Constructors

new(count : Int32 = 0)
Source

Class methods

increment(pointer : Pointer(StopSignal)) : Nil
Source

Instance methods

count
Source
count=(count : Int32)
Source