FAQ
https://github.com/cenkalti/go-sched

This was a learning project for me. Some of it's properties:

    - A generally useful event scheduler in Go.
    - Ported from Python's sched<http://hg.python.org/cpython/file/3.3/Lib/sched.py>module.
    - Uses priority queue internally.
    - Executes each event in a seperate goroutine.

It uses locks for synchronization. Is there a more Go-friendly way? How
would you implement it with channels?

Any advice would be great. Thanks in advance.

--
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

  • Aaron Blohowiak at Sep 28, 2013 at 10:30 pm
    you could also just launch a new goroutine for each call to .Enter(d, fn)
    that does a time.Sleep(n); and then does whatever you want it to.. then you
    let the golang's built-in scheduler do this work for you...

    http://play.golang.org/p/wHSUqIkfoB

    On Saturday, September 28, 2013 2:34:56 AM UTC-7, Cenk Altı wrote:

    https://github.com/cenkalti/go-sched

    This was a learning project for me. Some of it's properties:

    - A generally useful event scheduler in Go.
    - Ported from Python's sched<http://hg.python.org/cpython/file/3.3/Lib/sched.py>module.
    - Uses priority queue internally.
    - Executes each event in a seperate goroutine.

    It uses locks for synchronization. Is there a more Go-friendly way? How
    would you implement it with channels?

    Any advice would be great. Thanks in advance.
    --
    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.
  • Dmitry Vyukov at Sep 28, 2013 at 10:32 pm
    even simpler with time.AfterFunc:
    http://play.golang.org/p/sdKHcTUaXv

    On Sat, Sep 28, 2013 at 2:00 PM, wrote:
    you could also just launch a new goroutine for each call to .Enter(d, fn)
    that does a time.Sleep(n); and then does whatever you want it to.. then you
    let the golang's built-in scheduler do this work for you...

    http://play.golang.org/p/wHSUqIkfoB

    On Saturday, September 28, 2013 2:34:56 AM UTC-7, Cenk Altı wrote:

    https://github.com/cenkalti/go-sched

    This was a learning project for me. Some of it's properties:

    A generally useful event scheduler in Go.
    Ported from Python's sched module.
    Uses priority queue internally.
    Executes each event in a seperate goroutine.

    It uses locks for synchronization. Is there a more Go-friendly way? How
    would you implement it with channels?

    Any advice would be great. Thanks in advance.
    --
    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.
    --
    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.
  • Cenk Altı at Sep 29, 2013 at 4:14 pm
    Thanks for your answers. time.AfterFunc is the straightforward way indeed.
    However, I am planning to implement a server on top of it. Also, I will
    need to put a limit on the queue size and save the queue to disk at some
    interval. I think these requirements make it impossible to use the internal
    scheduler of Go.

    I will read more about channels and try to come up with a lock-free
    implementation.
    On Sunday, September 29, 2013 1:32:16 AM UTC+3, Dmitry Vyukov wrote:

    even simpler with time.AfterFunc:
    http://play.golang.org/p/sdKHcTUaXv


    On Sat, Sep 28, 2013 at 2:00 PM, <aaron.b...@gmail.com <javascript:>>
    wrote:
    you could also just launch a new goroutine for each call to .Enter(d, fn)
    that does a time.Sleep(n); and then does whatever you want it to.. then you
    let the golang's built-in scheduler do this work for you...

    http://play.golang.org/p/wHSUqIkfoB

    On Saturday, September 28, 2013 2:34:56 AM UTC-7, Cenk Altı wrote:

    https://github.com/cenkalti/go-sched

    This was a learning project for me. Some of it's properties:

    A generally useful event scheduler in Go.
    Ported from Python's sched module.
    Uses priority queue internally.
    Executes each event in a seperate goroutine.

    It uses locks for synchronization. Is there a more Go-friendly way? How
    would you implement it with channels?

    Any advice would be great. Thanks in advance.
    --
    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...@googlegroups.com <javascript:>.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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.
  • Matt Joiner at Sep 30, 2013 at 4:17 am
    Hi Cenk,

    In other runtimes where the cost of creating new contexts is prohibitive,
    analogues to Python's sched are necessary and useful. However go-routines
    are extremely cheap forms of concurrency, you should find that it's
    efficient enough follow the Aaron or Dmitry's suggestions. Creating your
    own scheduler is a needless duplication and wasteful abstraction.the sleep
    On Monday, September 30, 2013 2:14:12 AM UTC+10, Cenk Altı wrote:

    Thanks for your answers. time.AfterFunc is the straightforward way indeed.
    However, I am planning to implement a server on top of it. Also, I will
    need to put a limit on the queue size and save the queue to disk at some
    interval. I think these requirements make it impossible to use the internal
    scheduler of Go.

    I will read more about channels and try to come up with a lock-free
    implementation.
    On Sunday, September 29, 2013 1:32:16 AM UTC+3, Dmitry Vyukov wrote:

    even simpler with time.AfterFunc:
    http://play.golang.org/p/sdKHcTUaXv

    On Sat, Sep 28, 2013 at 2:00 PM, wrote:
    you could also just launch a new goroutine for each call to .Enter(d, fn)
    that does a time.Sleep(n); and then does whatever you want it to.. then you
    let the golang's built-in scheduler do this work for you...

    http://play.golang.org/p/wHSUqIkfoB

    On Saturday, September 28, 2013 2:34:56 AM UTC-7, Cenk Altı wrote:

    https://github.com/cenkalti/go-sched

    This was a learning project for me. Some of it's properties:

    A generally useful event scheduler in Go.
    Ported from Python's sched module.
    Uses priority queue internally.
    Executes each event in a seperate goroutine.

    It uses locks for synchronization. Is there a more Go-friendly way?
    How
    would you implement it with channels?

    Any advice would be great. Thanks in advance.
    --
    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...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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.
  • Matt Joiner at Sep 30, 2013 at 4:17 am
    -the sleep
    On Monday, September 30, 2013 2:17:15 PM UTC+10, Matt Joiner wrote:

    Hi Cenk,

    In other runtimes where the cost of creating new contexts is prohibitive,
    analogues to Python's sched are necessary and useful. However go-routines
    are extremely cheap forms of concurrency, you should find that it's
    efficient enough follow the Aaron or Dmitry's suggestions. Creating your
    own scheduler is a needless duplication and wasteful abstraction.the sleep
    On Monday, September 30, 2013 2:14:12 AM UTC+10, Cenk Altı wrote:

    Thanks for your answers. time.AfterFunc is the straightforward way
    indeed. However, I am planning to implement a server on top of it. Also, I
    will need to put a limit on the queue size and save the queue to disk at
    some interval. I think these requirements make it impossible to use the
    internal scheduler of Go.

    I will read more about channels and try to come up with a lock-free
    implementation.
    On Sunday, September 29, 2013 1:32:16 AM UTC+3, Dmitry Vyukov wrote:

    even simpler with time.AfterFunc:
    http://play.golang.org/p/sdKHcTUaXv

    On Sat, Sep 28, 2013 at 2:00 PM, wrote:
    you could also just launch a new goroutine for each call to .Enter(d, fn)
    that does a time.Sleep(n); and then does whatever you want it to.. then you
    let the golang's built-in scheduler do this work for you...

    http://play.golang.org/p/wHSUqIkfoB

    On Saturday, September 28, 2013 2:34:56 AM UTC-7, Cenk Altı wrote:

    https://github.com/cenkalti/go-sched

    This was a learning project for me. Some of it's properties:

    A generally useful event scheduler in Go.
    Ported from Python's sched module.
    Uses priority queue internally.
    Executes each event in a seperate goroutine.

    It uses locks for synchronization. Is there a more Go-friendly way?
    How
    would you implement it with channels?

    Any advice would be great. Thanks in advance.
    --
    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...@googlegroups.com.
    For more options, visit https://groups.google.com/groups/opt_out.
    --
    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
postedSep 28, '13 at 5:11p
activeSep 30, '13 at 4:17a
posts6
users4
websitegolang.org

People

Translate

site design / logo © 2022 Grokbase