{"id":20745662,"url":"https://github.com/christopheraue/m-ruby-concurrently","last_synced_at":"2025-04-24T06:45:00.975Z","repository":{"id":59152316,"uuid":"76277840","full_name":"christopheraue/m-ruby-concurrently","owner":"christopheraue","description":"A concurrency framework based on fibers for Ruby and mruby","archived":false,"fork":false,"pushed_at":"2018-12-17T02:00:13.000Z","size":583,"stargazers_count":17,"open_issues_count":1,"forks_count":3,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-04-22T12:08:03.095Z","etag":null,"topics":["concurrency","mruby","ruby"],"latest_commit_sha":null,"homepage":"","language":"Ruby","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/christopheraue.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-12-12T17:07:42.000Z","updated_at":"2025-02-09T00:23:37.000Z","dependencies_parsed_at":"2022-09-13T10:50:19.721Z","dependency_job_id":null,"html_url":"https://github.com/christopheraue/m-ruby-concurrently","commit_stats":null,"previous_names":[],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopheraue%2Fm-ruby-concurrently","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopheraue%2Fm-ruby-concurrently/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopheraue%2Fm-ruby-concurrently/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/christopheraue%2Fm-ruby-concurrently/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/christopheraue","download_url":"https://codeload.github.com/christopheraue/m-ruby-concurrently/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250580723,"owners_count":21453531,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["concurrency","mruby","ruby"],"created_at":"2024-11-17T07:21:44.196Z","updated_at":"2025-04-24T06:45:00.953Z","avatar_url":"https://github.com/christopheraue.png","language":"Ruby","readme":"# Concurrently\n\n[![Build Status](https://secure.travis-ci.org/christopheraue/m-ruby-concurrently.svg?branch=master)](http://travis-ci.org/christopheraue/m-ruby-concurrently)\n\nConcurrently is a concurrency framework for Ruby and mruby built upon\nfibers. With it code can be evaluated independently in its own execution\ncontext similar to a thread. Execution contexts are called *evaluations* in\nConcurrently and are created with [Kernel#concurrently][]:\n\n```ruby\nhello = concurrently do\n  wait 0.2 # seconds\n  \"hello\"\nend\n\nworld = concurrently do\n  wait 0.1 # seconds\n  \"world\"\nend\n\nputs \"#{hello.await_result} #{world.await_result}\" \n```\n\nIn this example we have three evaluations: The root evaluation and two more\nconcurrent evaluations started by said root evaluation. The root evaluation\nwaits until both concurrent evaluations were concluded and then prints \"hello\nworld\".\n\n\n## Synchronization with events\n\nEvaluations can be synchronized with certain events by waiting for them. These\nevents are:\n\n* an elapsed time period ([Kernel#wait][]),\n* readability and writability of IO ([IO#await_readable][],\n  [IO#await_writable][]) and\n* the result of another evaluation ([Concurrently::Proc::Evaluation#await_result][]).\n\nSince evaluations run independently they are not blocking other evaluations\nwhile waiting.\n\n\n## Concurrent I/O\n\nWhen doing I/O it is important to do it **non-blocking**. If the IO object is\nnot ready use [IO#await_readable][] and [IO#await_writable][] to await\nreadiness.\n\nFor more about non-blocking I/O, see the core ruby docs for\n[IO#read_nonblock][] and [IO#write_nonblock][].\n\nThis is a little server reading from an IO and printing the received messages:\n\n```ruby\n# Let's start with creating a pipe to connect client and server\nr,w = IO.pipe\n\n# Server:\n# We let the server code run concurrently so it runs independently. It reads\n# from the pipe non-blocking and awaits readability if the pipe is not readable.\nconcurrently do\n  while true\n    begin\n      puts r.read_nonblock 32\n    rescue IO::WaitReadable\n      r.await_readable\n      retry\n    end\n  end\nend\n\n# Client:\n# The client writes to the pipe every 0.5 seconds\nputs \"#{Time.now.strftime('%H:%M:%S.%L')} (Start time)\"\nwhile true\n  wait 0.5\n  w.write Time.now.strftime('%H:%M:%S.%L')\nend\n```\n\nThe root evaluation is effectively blocked by waiting or writing messages.\nBut since the server runs concurrently it is not affected by this and happily\nprints its received messages.\n\nThis is the output:\n\n```\n23:20:42.357 (Start time)\n23:20:42.858\n23:20:43.359\n23:20:43.860\n23:20:44.360\n...\n```\n\n\n## Documentation\n\n* [Installation][installation]\n* [An Overview of Concurrently][overview]\n* [API documentation][documentation]\n* [Troubleshooting][troubleshooting]\n* [Performance][performance]\n\n\n## Supported Ruby Versions\n\n* Ruby 2.2.7+\n* mruby 1.3+\n\n\n## Development\n\n[Release Notes][release_notes]\n\n\n## License\n\nCopyright 2016-present Christopher Aue\n\nConcurrently is licensed under the Apache License, Version 2.0. Please see the\nfile called LICENSE.\n\n\n[Kernel#concurrently]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/Kernel#concurrently-instance_method\n[Kernel#wait]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/Kernel#wait-instance_method\n[IO#await_readable]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/IO#await_readable-instance_method\n[IO#await_writable]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/IO#await_writable-instance_method\n[Concurrently::Proc::Evaluation#await_result]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/Concurrently/Proc/Evaluation#await_result-instance_method\n[IO#read_nonblock]: https://ruby-doc.org/core/IO.html#method-i-read_nonblock\n[IO#write_nonblock]: https://ruby-doc.org/core/IO.html#method-i-write_nonblock\n\n[installation]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/file/guides/Installation.md\n[overview]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/file/guides/Overview.md\n[documentation]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/index\n[troubleshooting]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/file/guides/Troubleshooting.md\n[performance]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/file/guides/Performance.md\n[release_notes]: http://www.rubydoc.info/github/christopheraue/m-ruby-concurrently/file/RELEASE_NOTES.md","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopheraue%2Fm-ruby-concurrently","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fchristopheraue%2Fm-ruby-concurrently","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fchristopheraue%2Fm-ruby-concurrently/lists"}