What is Ruby Concurrent?

Overview of a Ruby gem designed as a set of concurrency tools
01 September 2017   1743

Concurrency is a form of computing in which several computations are executed during overlapping time periods—concurrently—instead of sequentially (one completing before the next starts). This is a property of a system—this may be an individual program, a computer, or a network—and there is a separate execution point or "thread of control" for each computation ("process"). A concurrent system is one where a computation can advance without waiting for all other computations to complete.

Modern concurrency tools include agents, futures, promises, thread pools actors, supervisors etc.Concurrent Ruby makes the strongest thread safety guarantees of any Ruby concurrency library. Every abstraction in this library is thread safe. Similarly, all are deadlock free and many are fully lock free.

Concurrent Ruby is a set of Modern concurrency tools for Ruby. Inspired by Erlang, Clojure, Scala, Haskell, F#, C#, Java, and classic concurrency patterns.

The design goals of this gem are:

  • Be an 'unopinionated' toolbox that provides useful utilities without debating which is better or why
  • Remain free of external gem dependencies
  • Stay true to the spirit of the languages providing inspiration
  • But implement in a way that makes sense for Ruby
  • Keep the semantics as idiomatic Ruby as possible
  • Support features that make sense in Ruby
  • Exclude features that don't make sense in Ruby
  • Be small, lean, and loosely coupled

Concurrency Abstractions

  • Async (Concurrent::Async): A mixin module that provides simple asynchronous behavior to a class, turning it into a simple actor.
  • Future (Concurrent::Future): An asynchronous operation that produces a value. It represents a promise to complete an action at some time in the future.
    • Dataflow: Built on Futures, Dataflow allows you to create a task that will be scheduled when all of its data dependencies are available.
  • Promise (Concurrent::Promise): Similar to Futures, with more features. It represents the eventual value returned from the single completion of an operation.
  • ScheduledTask (Concurrent::ScheduledTask): Like a Future scheduled for a specific future time.
  • TimerTask (Concurrent::TimerTask): A Thread that periodically wakes up to perform work at regular intervals.

Installation

gem install concurrent-ruby

or add the following line to Gemfile:

gem 'concurrent-ruby', require: 'concurrent'

and run bundle install from your shell

Usage

Everything within this gem can be loaded simply by requiring it:

require 'concurrent'

To use the tools in the Edge gem it must be required separately:

require 'concurrent-edge'

See GitHub for more info.

RubyMine 2018.2 to be Released

Great news for Ruby developers - new version of popular IDE available now
27 July 2018   194

Major summer update of the integrated development environment RubyMine from JetBrains under the number 2018.2 released. Among the innovations - improving the work with the code, support for new version managers, re-testing only for failed tests and much more.

Code analysis

The new version of IDE has received an improved type inference that allows to better read the types of elements in blocks, arrays and hashes. This feature improves code autocompletion and navigation throughout the project:

Element CompletionElement Completion

In addition, RubyMine now correctly recognizes models using polymorphic associations, and offers them full support for "smart" functions.

Version Managers

The updated development environment now supports chruby and asdf. Moreover, now all version managers are available in WSL, Docker, SSH and other remote connections.

Testing

RubyMine 2018.2 allows you to retest only those tests that have not been tested. According to the developers, this frees the user from manually viewing each failed check. The new function also works with the rake test and rake spec presets:

Rerun Failed Tests
Rerun Failed Tests

YAML

In this update, developers paid attention to the YAML data serialization format. Now its code can be formatted directly in the IDE and use all the functions of autocomplete and navigation by code. Moreover, the new version of RubyMine provides automatic filling of YAML data structures that have JSON Schema files, and the ability to copy / paste the key path to the value in .yml files.

Git

Support for version control in RubyMine 2018.2 has received several new features:

  • files with a merge conflict are now grouped in a separate node;
  • a new action Browse Repository at Revision allows you to examine the state of the repository after each revision;
  • It was possible to skip the Push action during the Commit and Push command or use it only for protected branches;
  • you can connect an unlimited number of accounts to GitHub and select the main one for each project.

Other improvements

In addition to general performance improvements, the new version of IDE brought new icons, a dark theme for MacOS, support for the Touch Bar, improved support for JS, TypeScript and CoffeeScript, which you can see in the overview of the WebStorm 2018.2 IDE update, and connect the debugger to remote processes without having to reboot .