I'm running a mac cocoa event loop, and calling a go ticker:

void StartApp() {
    [NSAutoreleasePool new];
    [NSApplication sharedApplication];
    [NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];
    [NSApp run];

func test() {
 last := time.Now()
 ticker := time.NewTicker(time.Second)
 for range ticker.C {
     t := time.Now()
     diff := t.Sub(last)
     if diff > time.Second*2 {
         fmt.Println("Tick slow:", diff)
     last = t

func main() {
 go test()

currenly just running the go program from the terminal, though I got 
similar results packaging it into an app.

I soon get very long periods between ticker fires:

Tick slow: 3.501350114s
Tick slow: 5.551485377s

This seems to only happen with 

[NSApp setActivationPolicy:NSApplicationActivationPolicyRegular];

NSApplicationActivationPolicyProhibited and 
NSApplicationActivationPolicyAccessory don't cause this.

I assume it's the event loop in [NSApp run] that is causing this, but don't 
know how to start making a mac appliction with goroutines and tickers that 
don't get blocked.

Does anybody know how to avoid this and why it is happening?


You received this message because you are subscribed to the Google Groups 
"golang-nuts" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to golang-nuts+unsubscr...@googlegroups.com.
To view this discussion on the web visit 

Reply via email to