Skip to main content

Thread

                            
                              
                                class 
                                Thread
                              
                              

A class representing an individual thread.

Thread is a wrapper for a generator that can be executed concurrently.

Aside from the main thread, all threads need to have a parent.If a parent finishes execution, all of its child threads are terminated.

Constructors

constructor

                            
                              
                                public 
                                new
                                Thread
                                
                                  
                                    
                                      runner
                                      : 
                                      ThreadGenerator
                                    
                                  
                                
                                : 
                                Thread
                              
                              

Parameters

Properties

children

                            
                              
                                public 
                                children
                                : 
                                Thread
                                [] = 
                                []
                              
                              

parent

                            
                              
                                public 
                                parent
                                : 
                                
                                  
                                    
                                      null
                                    
                                    
                                      Thread
                                    
                                  
                                
                                 = 
                                null
                              
                              

runner

                            
                              
                                readonly 
                                public 
                                runner
                                : 
                                ThreadGenerator
                              
                              

The generator wrapped by this thread.


time

                            
                              
                                readonly 
                                public 
                                time
                                : 
                                SimpleSignal
                                
                                  
                                    
                                      number
                                    
                                    
                                      void
                                    
                                  
                                
                                 = 
                                ...
                              
                              

The current time of this thread.

Used by waitFor and other time-based functions to properlysupport durations shorter than one frame.


value

                            
                              
                                public 
                                value
                                : 
                                unknown
                              
                              

The next value to be passed to the wrapped generator.

Accessors

canceled

                            
                              
                                public 
                                get 
                                canceled
                                (): 
                                boolean
                              
                              

Check if this thread or any of its ancestors has been canceled.


fixed

                            
                              
                                public 
                                get 
                                fixed
                                (): 
                                number
                              
                              

The fixed time of this thread.

Fixed time is a multiple of the frame duration. It can be used to accountfor the difference between this thread's time and the time of thecurrent animation frame.


paused

                            
                              
                                public 
                                get 
                                paused
                                (): 
                                boolean
                              
                              

Methods

add

                            
                              
                                public 
                                add
                                
                                  
                                    
                                      child
                                      : 
                                      Thread
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


cancel

                            
                              
                                public 
                                cancel
                                (): 
                                void
                              
                              

next

                            
                              
                                public 
                                next
                                (): 
                                
                                  
                                    
                                      IteratorYieldResult
                                      
                                        
                                          
                                            
                                              
                                                
                                                  void
                                                
                                                
                                                  Promise
                                                  
                                                    
                                                      
                                                        any
                                                      
                                                    
                                                  
                                                
                                                
                                                  ThreadGenerator
                                                
                                                
                                                  Promisable
                                                  
                                                    
                                                      
                                                        any
                                                      
                                                    
                                                  
                                                
                                              
                                            
                                          
                                        
                                      
                                    
                                    
                                      IteratorReturnResult
                                      
                                        
                                          
                                            void
                                          
                                        
                                      
                                    
                                    
                                      
                                        
                                          
                                            done
                                            : 
                                            boolean
                                             = 
                                            false
                                          
                                          
                                            value
                                            : 
                                            null
                                             = 
                                            null
                                          
                                        
                                      
                                    
                                  
                                
                              
                              

Progress the wrapped generator once.


pause

                            
                              
                                public 
                                pause
                                
                                  
                                    
                                      value
                                      : 
                                      boolean
                                    
                                  
                                
                                : 
                                void
                              
                              

Parameters


update

                            
                              
                                public 
                                update
                                
                                  
                                    
                                      dt
                                      : 
                                      number
                                    
                                  
                                
                                : 
                                void
                              
                              

Prepare the thread for the next update cycle.

Parameters

  • dt : number

    The delta time of the next cycle.