func init() {
	work = make(chan func(), 32)
	keyC = make(chan Key, 1024)
	windows = make(map[int]*Window)
	windower2window = make(map[Windower]*Window)

	// setup render queue
	// we do this song and dance in order to be able to deal with slow
	// connections where rendering could take a long time
	execute := make(chan bool, 1)
	fa := make([]func(), 0, 20)
	mtx := sync.Mutex{}

	var wg sync.WaitGroup
	wg.Add(2)
	go func() {
		wg.Done()
		for range execute {
			for {
				// get work off queue
				mtx.Lock()
				if len(fa) == 0 {
					mtx.Unlock()
					break
				}
				f := fa[0]
				fa[0] = nil // just in case to prevent leak
				fa = fa[1:]
				mtx.Unlock()

				// actually do work
				f()
			}
		}
	}()

	go func() {
		wg.Done()
		for f := range work {
			// queue work
			mtx.Lock()
			fa = append(fa, f)
			mtx.Unlock()

			// tell executer there is work
			select {
			case execute <- true:
			default:
			}
		}
	}()
	wg.Wait()
}
func init() {
	work = make(chan func(), 32)
	keyC = make(chan Key, 1024)
	windows = make(map[int]*Window)
	windower2window = make(map[Windower]*Window)

	
	
	
	execute := make(chan bool, 1)
	fa := make([]func(), 0, 20)
	mtx := sync.Mutex{}

	var wg sync.WaitGroup
	wg.Add(2)
	go func() {
		wg.Done()
		for range execute {
			for {
				
				mtx.Lock()
				if len(fa) == 0 {
					mtx.Unlock()
					break
				}
				f := fa[0]
				fa[0] = nil 
				fa = fa[1:]
				mtx.Unlock()

				
				f()
			}
		}
	}()

	go func() {
		wg.Done()
		for f := range work {
			
			mtx.Lock()
			fa = append(fa, f)
			mtx.Unlock()

			
			select {
			case execute <- true:
			default:
			}
		}
	}()
	wg.Wait()
}
func init ( ) { work = make ( chan func ( ) , 32 ) keyC = make ( chan Key , 1024 ) windows = make ( map [ int ] * Window ) windower2window = make ( map [ Windower ] * Window ) // setup render queue // we do this song and dance in order to be able to deal with slow // connections where rendering could take a long time execute := make ( chan bool , 1 ) fa := make ( [ ] func ( ) , 0 , 20 ) mtx := sync . Mutex { } var wg sync . WaitGroup wg . Add ( 2 ) go func ( ) { wg . Done ( ) for range execute { for { // get work off queue mtx . Lock ( ) if len ( fa ) == 0 { mtx . Unlock ( ) break } f := fa [ 0 ] fa [ 0 ] = nil // just in case to prevent leak fa = fa [ 1 : ] mtx . Unlock ( ) // actually do work f ( ) } } } ( ) go func ( ) { wg . Done ( ) for f := range work { // queue work mtx . Lock ( ) fa = append ( fa , f ) mtx . Unlock ( ) // tell executer there is work select { case execute <- true : default : } } } ( ) wg . Wait ( ) }
// init sets up all global variables and prepares ttk for use.
init sets up all global variables and prepares ttk for use .