fbpx
Wikipedia

Rinda (Ruby programming language)

Rinda is a software library for creating modular and distributed co-operating services in Ruby using the tuple space or Linda distributed computing paradigm.

Based on a source code initially released to the Ruby community by Masatoshi SEKI in 2000,[1] Rinda was later absorbed into Ruby's core distributed Ruby (DRb) module. Rinda has been distributed as part of the core Ruby library since Ruby 1.8.

Example usage edit

Rinda provides a framework by which multiple Ruby processes (which or may not be running on the same machine) can add, access and modify tuples (an ordered list of elements) stored in a shared data repository (the tuplespace).

For example, the following program creates a new Rinda tuplespace and initializes a DRb service that waits for requests coming over the network.

require 'rinda/tuplespace' URI = "druby://localhost:61676" DRb.start_service(URI, Rinda::TupleSpace.new) DRb.thread.join 

Using Rinda, other applications can poll the tuplespace for tuples that match specific criteria.

For example, the program below connects to a Rinda service and listens for any tuple composed an arithmetic operator followed two numbers (such as the sequence "+ 2 4") When such a tuple is discovered the program computes the result of the mathematical operation (for example, processing "+ 2 4" into "6") and stores it in tuplespace.

require 'rinda/rinda' URI = "druby://localhost:61676" DRb.start_service ts = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, URI)) loop do  ops, a, b = ts.take([ %r{^[-+/*]$}, Numeric, Numeric])  ts.write(["result", a.send(ops, b)]) end 

Finally, Rinda applications can add or remove tuples from the tuplespace.

For instance, the following program posts prefix arithmetic tuples to the tuplespace and reads back the result (posted by the program above).

require 'rinda/rinda' URI = "druby://localhost:61676" DRb.start_service ts = Rinda::TupleSpaceProxy.new(DRbObject.new(nil, URI)) tuples = [["*", 2, 2 ], [ "+", 2, 5 ], [ "-", 9, 3 ]] tuples.each do |t|  ts.write(t)  res = ts.take(["result", nil])  puts "#{res[1]} = #{t[1]} #{t[0]} #{t[2]}" end 

References edit

  1. ^ "Tuplespace". Ruby Application Archive (RAA). Retrieved 26 October 2011.

External links edit

  • Ruby Standard Library Documentation for Rinda


rinda, ruby, programming, language, this, article, needs, additional, citations, verification, please, help, improve, this, article, adding, citations, reliable, sources, unsourced, material, challenged, removed, find, sources, rinda, ruby, programming, langua. This article needs additional citations for verification Please help improve this article by adding citations to reliable sources Unsourced material may be challenged and removed Find sources Rinda Ruby programming language news newspapers books scholar JSTOR April 2016 Learn how and when to remove this message Rinda is a software library for creating modular and distributed co operating services in Ruby using the tuple space or Linda distributed computing paradigm Based on a source code initially released to the Ruby community by Masatoshi SEKI in 2000 1 Rinda was later absorbed into Ruby s core distributed Ruby DRb module Rinda has been distributed as part of the core Ruby library since Ruby 1 8 Example usage editRinda provides a framework by which multiple Ruby processes which or may not be running on the same machine can add access and modify tuples an ordered list of elements stored in a shared data repository the tuplespace For example the following program creates a new Rinda tuplespace and initializes a DRb service that waits for requests coming over the network require rinda tuplespace URI druby localhost 61676 DRb start service URI Rinda TupleSpace new DRb thread join Using Rinda other applications can poll the tuplespace for tuples that match specific criteria For example the program below connects to a Rinda service and listens for any tuple composed an arithmetic operator followed two numbers such as the sequence 2 4 When such a tuple is discovered the program computes the result of the mathematical operation for example processing 2 4 into 6 and stores it in tuplespace require rinda rinda URI druby localhost 61676 DRb start service ts Rinda TupleSpaceProxy new DRbObject new nil URI loop do ops a b ts take r Numeric Numeric ts write result a send ops b end Finally Rinda applications can add or remove tuples from the tuplespace For instance the following program posts prefix arithmetic tuples to the tuplespace and reads back the result posted by the program above require rinda rinda URI druby localhost 61676 DRb start service ts Rinda TupleSpaceProxy new DRbObject new nil URI tuples 2 2 2 5 9 3 tuples each do t ts write t res ts take result nil puts res 1 t 1 t 0 t 2 endReferences edit Tuplespace Ruby Application Archive RAA Retrieved 26 October 2011 External links editRuby Standard Library Documentation for Rinda nbsp This programming tool related article is a stub You can help Wikipedia by expanding it vte Retrieved from https en wikipedia org w index php title Rinda Ruby programming language amp oldid 1214860910, wikipedia, wiki, book, books, library,

article

, read, download, free, free download, mp3, video, mp4, 3gp, jpg, jpeg, gif, png, picture, music, song, movie, book, game, games.