# What are Rinda and tuple spaces?

> Rinda is Ruby's implementation of the Linda tuple space model: a shared board where processes leave and collect tuples instead of calling each other.

Source: https://druby.com/rinda/what-is-rinda/  
Section: Rinda  
Updated: 2026-12-05

Rinda is a Ruby library, built on dRuby, that implements the tuple space model from the Linda coordination language. A tuple space is a shared place where processes leave small lists of values, called tuples, and other processes pick them up by describing the shape of the tuple they want. The processes never call each other directly.

## The model

Think of a noticeboard that any process can reach.

- A process **writes** a tuple to the board, for example `[:job, 42, 'resize']`.
- Another process **takes** a tuple that matches a pattern, for example `[:job, nil, nil]`, where `nil` means "anything". Taking removes the tuple from the board.
- A process can also **read** a matching tuple, which returns a copy and leaves the original in place.

If no tuple matches, `take` and `read` wait until one arrives. That waiting is what makes the model useful: a worker can simply ask for the next job and sleep until there is one.

## Why use it instead of plain dRuby calls

With plain dRuby, the caller must know which object to call and that object must be running at that moment. With a tuple space:

- **Producers and consumers do not know each other.** A producer writes a job. Whichever worker asks first gets it.
- **They do not have to be running at the same time.** A tuple waits in the space until someone takes it.
- **Adding capacity is trivial.** Start another worker that takes from the same pattern.
- **Take is exclusive.** A tuple that has been taken is gone, so two workers cannot take the same job.

## A minimal example

In a single process, to show the three operations:

```ruby
require 'rinda/tuplespace'

ts = Rinda::TupleSpace.new

ts.write([:job, 1, 'resize'])
ts.write([:job, 2, 'crop'])

p ts.read([:job, nil, nil])   # => [:job, 1, "resize"], still in the space
p ts.take([:job, 2, nil])     # => [:job, 2, "crop"], now removed
p ts.read_all([:job, nil, nil]).size   # => 1
```

To share the space between processes, publish it as a dRuby front object. That is covered on [TupleSpace: write, take and read](/rinda/tuplespace-write-take-read/).

## What is in the library

| Class | Purpose |
| --- | --- |
| `Rinda::TupleSpace` | The space itself |
| `Rinda::TupleSpaceProxy` | A wrapper for a remote space that makes `take` safer over the network |
| `Rinda::RingServer`, `Rinda::RingFinger`, `Rinda::RingProvider` | Finding a tuple space and other services on the local network, see [RingServer and RingFinger](/rinda/ringserver-and-ringfinger/) |

## Limits to know about

- A `Rinda::TupleSpace` lives in memory in one process. If that process stops, the tuples are gone.
- It is built on dRuby, so everything on [the safety pages](/safety/never-expose-drb-to-untrusted-networks/) applies to it.
- Tuples are passed by value, so what you get back is a copy of what was written. See [pass by value and pass by reference](/guide/pass-by-value-and-by-reference/).

## Installing

Rinda is a bundled gem from Ruby 3.4. Under Bundler, add `gem 'rinda'` next to `gem 'drb'`. Details are on [installing dRuby](/guide/installing-drb/).
