https://github.com/yegor256/syncem
A simple Ruby decorator to make all methods of your object thread-safe
https://github.com/yegor256/syncem
ruby ruby-gem thread-safety threading
Last synced: about 1 year ago
JSON representation
A simple Ruby decorator to make all methods of your object thread-safe
- Host: GitHub
- URL: https://github.com/yegor256/syncem
- Owner: yegor256
- License: mit
- Created: 2019-03-06T19:14:51.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2024-10-15T15:39:49.000Z (over 1 year ago)
- Last Synced: 2024-10-16T19:34:16.582Z (over 1 year ago)
- Topics: ruby, ruby-gem, thread-safety, threading
- Language: Ruby
- Homepage: https://rubygems.org/gems/syncem
- Size: 91.8 KB
- Stars: 11
- Watchers: 4
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE.txt
Awesome Lists containing this project
README

[](https://www.elegantobjects.org)
[](http://www.rultor.com/p/yegor256/syncem)
[](https://www.jetbrains.com/ruby/)
[](https://github.com/yegor256/syncem/actions/workflows/rake.yml)
[](http://badge.fury.io/rb/syncem)
[](https://codeclimate.com/github/yegor256/syncem/maintainability)
[](http://rubydoc.info/github/yegor256/syncem/master/frames)
[](https://hitsofcode.com/view/github/yegor256/syncem)
[](https://github.com/yegor256/syncem/blob/master/LICENSE.txt)
Read this blog post:
[_SyncEm: Thread-Safe Decorators in Ruby_](https://www.yegor256.com/2019/06/26/syncem.html).
Sometimes you have an object that is not thread-safe,
but you need to make sure each of its methods is thread-safe, because they
deal with some resources, like files or databases and you want them to
manage those resources sequentially. This small gem will help you achieve
exactly that without any re-design of the objects you already have. Just
decorate them with `SyncEm` [thread-safe decorator](https://www.yegor256.com/2017/01/17/synchronized-decorators.html)
and that is it.
First, install it:
```bash
$ gem install syncem
```
Then, use it like this:
```ruby
require 'syncem'
obj = SyncEm.new(obj)
```
That's it.
## How to contribute
Read [these guidelines](https://www.yegor256.com/2014/04/15/github-guidelines.html).
Make sure your build is green before you contribute
your pull request. You will need to have [Ruby](https://www.ruby-lang.org/en/) 2.3+ and
[Bundler](https://bundler.io/) installed. Then:
```
$ bundle update
$ bundle exec rake
```
If it's clean and you don't see any error messages, submit your pull request.