Code Monkey home page Code Monkey logo

unique_thread's People

Contributors

br1ght0ne avatar ferdy89 avatar ivanovyordan avatar taylorzr avatar

Stargazers

 avatar  avatar

Watchers

 avatar  avatar

unique_thread's Issues

Introduce a `UniqueThread.loop` shorthand

The interface would look like:

UniqueThread.loop('lock_name', sleep: 30) do
  # do something every 30 seconds
end

This seems to be the most common use case for this gem so far, so it makes sense to have a shorthand for it.

Move retry mechanism from `run` to `loop`

The way the gem is shaping, the run interface will be the "raw" one for a thread that mimics the Ruby one, while loop is the advanced one with features like looping, sleeping and now retrying.

Create examples

Besides the written explanation of the use cases in the README, we should have a directory with some live code examples. This should help folks integrate them into their projects without having to think too much.

Introduce a `UniqueThread.run` shorthand

This interface will replace:

UniqueThread.new('lock_name').run do

and transform it into

UniqueThread.run('my_lock') do

This simplifies the public interface and makes it similar to the one from #5.

Add a way to exit the thread

On a previously reported issue it was mentioned that there's no way to exit a UniqueThread. If an error occurs, the thread dies but it keeps the lock.

We should have some sort of UniqueThread::ExitError that a user can throw to terminate the thread AND liberate the lock.

Eliminate `sleep` calls from tests

The unit tests currently use a few calls to sleep with very small waits in order to give control to the thread.

These calls don't hurt "much" to the test time because the few tests we have run in a couple seconds anyway. However, it probably is a smell of a lack of understanding of how we interface with the gem.

For example, if the gem was a regular Thread, the proper way of handling control to it would be to wait. However, the gem it's not really a thread, so this is not possible.

The point of this task is to go in that direction: think (and implement) a way to test UniqueThread in a similar way that one would deal with a regular Thread

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.