Documentation ¶
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
var CallQueueCap = 16
CallQueueCap is the capacity of the call queue. This means how many calls to CallNonBlock will not block until some call finishes.
The default value is 16 and should be good for 99% usecases.
Functions ¶
func Call ¶
func Call(f func())
Call queues function f on the main thread and blocks until the function f finishes.
func CallNonBlock ¶
func CallNonBlock(f func())
CallNonBlock queues function f on the main thread and returns immediately. Does not wait until f finishes.
func CallVal ¶
func CallVal(f func() interface{}) interface{}
CallVal queues function f on the main thread and returns a value returned by f.
func Run ¶
func Run(run func())
Run enables mainthread package functionality. To use mainthread package, put your main function code into the run function (the argument to Run) and simply call Run from the real main function.
Run returns when run (argument) function finishes.
Example ¶
package main import ( "fmt" "github.com/faiface/mainthread" ) func run() { mainthread.Call(func() { fmt.Println("i'm printing from the main thread") }) } func main() { mainthread.Run(run) }
Output: i'm printing from the main thread
Types ¶
This section is empty.