FAQ
I have an app that turns on our house lights at sunset. The app works like
this:

1. Calculate the duration until the next Sunset
2. Call time.After() for that duration and block on the retuned channel
3. Turn the lights on.
4. Start over at step 1

Two days ago, the app was nearly 10 minutes late at turning on our lights,
but the next night our lights turned on at the right time. I believe that
my goroutine was blocked waiting too long for time.After().

1. Is it possible for reading the channel from time.After(d) to block
significantly longer than d?
2. Mac OS can put the computer to sleep. It used to be that web servers
running on sleeping Macs would not work, but apple must have fixed this as
our computer is set to sleep, yet it successfully serves pages while it
sleeps. Could a sleeping mac affect running goroutines?
3. Would calling time.After(time.Minute) in a while loop instead of calling
time.After() to wait nearly 1 day help?

--
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+unsubscribe@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.

Search Discussions

  • Andy Balholm at Nov 8, 2013 at 4:36 pm

    On Friday, November 8, 2013 8:09:00 AM UTC-8, Travis Keep wrote:

    I have an app that turns on our house lights at sunset. The app works like
    this:

    1. Calculate the duration until the next Sunset
    2. Call time.After() for that duration and block on the retuned channel
    3. Turn the lights on.
    4. Start over at step 1

    Two days ago, the app was nearly 10 minutes late at turning on our lights,
    but the next night our lights turned on at the right time. I believe that
    my goroutine was blocked waiting too long for time.After().

    1. Is it possible for reading the channel from time.After(d) to block
    significantly longer than d?
    Definitely. Time.After is documented as using time.NewTimer, the
    documentation for which says "after at least duration d".

    Recent versions of MacOS are very aggressive in coalescing timers to reduce
    CPU load. Most of this has to do with high-frequency timers; I don't know
    what it does with 24-hour ones.

    2. Mac OS can put the computer to sleep. It used to be that web servers
    running on sleeping Macs would not work, but apple must have fixed this as
    our computer is set to sleep, yet it successfully serves pages while it
    sleeps. Could a sleeping mac affect running goroutines?
    3. Would calling time.After(time.Minute) in a while loop instead of
    calling time.After() to wait nearly 1 day help?
    Yes. Or your could sleep for an hour at a time until it gets to within less
    than an hour and a half from sunset, then switch to shorter sleeps.

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
  • Ibrahim M. Ghazal at Nov 9, 2013 at 5:53 am

    On Fri, Nov 8, 2013 at 7:09 PM, Travis Keep wrote:
    3. Turn the lights on.
    I'm curious about this. What kind of controller are you using, and how
    are you communicating with it?

    --
    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+unsubscribe@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
groupgolang-nuts @
categoriesgo
postedNov 8, '13 at 4:09p
activeNov 9, '13 at 5:53a
posts3
users3
websitegolang.org

People

Translate

site design / logo © 2021 Grokbase