Forum: Ruby-core [ruby-trunk - Feature #8128][Open] New primitives for Rinda::TupleSpace

Posted by Joel Vanderwerf (vjoel)
on 2013-03-20 00:00
(Received via mailing list)
Issue #8128 has been reported by vjoel (Joel VanderWerf).

----------------------------------------
Feature #8128: New primitives for Rinda::TupleSpace
https://bugs.ruby-lang.org/issues/8128

Author: vjoel (Joel VanderWerf)
Status: Open
Priority: Low
Assignee:
Category: lib
Target version:


=begin

= New primitives for Rinda::TupleSpace

This issue proposes adding two new primitives to TupleSpace for atomic 
bulk operations:

== 1. TupleSpace#replace_all

=== What it does

Calling

  replace_all(tuple, new_tuple, sec=nil)

atomically removes all tuples matching ((|tuple|)) and writes 
((|new_tuple|)). It does not block waiting for tuples. The return value 
is a pair:

  [ matching_tuples, entry ]

where ((|matching_tuples|)) is like the return value of 
(({read_all(tuple)})) and
((|entry|)) is like the return value of (({write(new_tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives. As 
noted in ((*The dRuby Book*)), p. 176, "It isn't easy to represent a 
dictionary using TupleSpace." Essentially, the #[]= and #[] operations 
must take/write a global lock tuple.

Using #replace_all, it is easy to implement a key-value store without 
lock tuples. See key-value-store.rb for an example.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the replace_all functionality.


=== Examples

See key-value-store.rb and example-replace-all.rb.


== 2. TupleSpace#take_all

=== What it does

Calling

  take_all(tuple)

atomically removes all matching tuples. It does not block waiting for 
tuples. The return value is the array of tuples, like the return value 
of (({read_all(tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives, 
though in this case atomicity may not be important. More importantly, it 
is not possible to do this efficiently with existing primitives. The 
best approximation would be an unbounded sequence of #take calls.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the take_all functionality.


=== Examples

See example-take-all.rb.

=end
Posted by hsbt (Hiroshi SHIBATA) (Guest)
on 2013-03-20 00:07
(Received via mailing list)
Issue #8128 has been updated by hsbt (Hiroshi SHIBATA).

Assignee set to seki (Masatoshi Seki)


----------------------------------------
Feature #8128: New primitives for Rinda::TupleSpace
https://bugs.ruby-lang.org/issues/8128#change-37745

Author: vjoel (Joel VanderWerf)
Status: Open
Priority: Low
Assignee: seki (Masatoshi Seki)
Category: lib
Target version:


=begin

= New primitives for Rinda::TupleSpace

This issue proposes adding two new primitives to TupleSpace for atomic 
bulk operations:

== 1. TupleSpace#replace_all

=== What it does

Calling

  replace_all(tuple, new_tuple, sec=nil)

atomically removes all tuples matching ((|tuple|)) and writes 
((|new_tuple|)). It does not block waiting for tuples. The return value 
is a pair:

  [ matching_tuples, entry ]

where ((|matching_tuples|)) is like the return value of 
(({read_all(tuple)})) and
((|entry|)) is like the return value of (({write(new_tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives. As 
noted in ((*The dRuby Book*)), p. 176, "It isn't easy to represent a 
dictionary using TupleSpace." Essentially, the #[]= and #[] operations 
must take/write a global lock tuple.

Using #replace_all, it is easy to implement a key-value store without 
lock tuples. See key-value-store.rb for an example.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the replace_all functionality.


=== Examples

See key-value-store.rb and example-replace-all.rb.


== 2. TupleSpace#take_all

=== What it does

Calling

  take_all(tuple)

atomically removes all matching tuples. It does not block waiting for 
tuples. The return value is the array of tuples, like the return value 
of (({read_all(tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives, 
though in this case atomicity may not be important. More importantly, it 
is not possible to do this efficiently with existing primitives. The 
best approximation would be an unbounded sequence of #take calls.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the take_all functionality.


=== Examples

See example-take-all.rb.

=end
Posted by drbrain (Eric Hodel) (Guest)
on 2013-03-23 08:45
(Received via mailing list)
Issue #8128 has been updated by drbrain (Eric Hodel).

Status changed from Open to Assigned
Priority changed from Low to Normal

A TupleSpace isn't designed for these types of operations, see: 
http://www.lindaspaces.com/book/ (the TupleSpace book).
----------------------------------------
Feature #8128: New primitives for Rinda::TupleSpace
https://bugs.ruby-lang.org/issues/8128#change-37844

Author: vjoel (Joel VanderWerf)
Status: Assigned
Priority: Normal
Assignee: seki (Masatoshi Seki)
Category: lib
Target version:


=begin

= New primitives for Rinda::TupleSpace

This issue proposes adding two new primitives to TupleSpace for atomic 
bulk operations:

== 1. TupleSpace#replace_all

=== What it does

Calling

  replace_all(tuple, new_tuple, sec=nil)

atomically removes all tuples matching ((|tuple|)) and writes 
((|new_tuple|)). It does not block waiting for tuples. The return value 
is a pair:

  [ matching_tuples, entry ]

where ((|matching_tuples|)) is like the return value of 
(({read_all(tuple)})) and
((|entry|)) is like the return value of (({write(new_tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives. As 
noted in ((*The dRuby Book*)), p. 176, "It isn't easy to represent a 
dictionary using TupleSpace." Essentially, the #[]= and #[] operations 
must take/write a global lock tuple.

Using #replace_all, it is easy to implement a key-value store without 
lock tuples. See key-value-store.rb for an example.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the replace_all functionality.


=== Examples

See key-value-store.rb and example-replace-all.rb.


== 2. TupleSpace#take_all

=== What it does

Calling

  take_all(tuple)

atomically removes all matching tuples. It does not block waiting for 
tuples. The return value is the array of tuples, like the return value 
of (({read_all(tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives, 
though in this case atomicity may not be important. More importantly, it 
is not possible to do this efficiently with existing primitives. The 
best approximation would be an unbounded sequence of #take calls.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the take_all functionality.


=== Examples

See example-take-all.rb.

=end
Posted by seki (Masatoshi Seki) (Guest)
on 2013-03-23 22:19
(Received via mailing list)
Issue #8128 has been updated by seki (Masatoshi Seki).

Status changed from Assigned to Rejected

I think so: https://twitter.com/drbrain/status/315510564233293825

This is a global lock. If you want a KVS, I recommend the Hash or Drip.
----------------------------------------
Feature #8128: New primitives for Rinda::TupleSpace
https://bugs.ruby-lang.org/issues/8128#change-37869

Author: vjoel (Joel VanderWerf)
Status: Rejected
Priority: Normal
Assignee: seki (Masatoshi Seki)
Category: lib
Target version:


=begin

= New primitives for Rinda::TupleSpace

This issue proposes adding two new primitives to TupleSpace for atomic 
bulk operations:

== 1. TupleSpace#replace_all

=== What it does

Calling

  replace_all(tuple, new_tuple, sec=nil)

atomically removes all tuples matching ((|tuple|)) and writes 
((|new_tuple|)). It does not block waiting for tuples. The return value 
is a pair:

  [ matching_tuples, entry ]

where ((|matching_tuples|)) is like the return value of 
(({read_all(tuple)})) and
((|entry|)) is like the return value of (({write(new_tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives. As 
noted in ((*The dRuby Book*)), p. 176, "It isn't easy to represent a 
dictionary using TupleSpace." Essentially, the #[]= and #[] operations 
must take/write a global lock tuple.

Using #replace_all, it is easy to implement a key-value store without 
lock tuples. See key-value-store.rb for an example.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the replace_all functionality.


=== Examples

See key-value-store.rb and example-replace-all.rb.


== 2. TupleSpace#take_all

=== What it does

Calling

  take_all(tuple)

atomically removes all matching tuples. It does not block waiting for 
tuples. The return value is the array of tuples, like the return value 
of (({read_all(tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives, 
though in this case atomicity may not be important. More importantly, it 
is not possible to do this efficiently with existing primitives. The 
best approximation would be an unbounded sequence of #take calls.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the take_all functionality.


=== Examples

See example-take-all.rb.

=end
Posted by Joel Vanderwerf (vjoel)
on 2013-03-27 00:07
(Received via mailing list)
Issue #8128 has been updated by vjoel (Joel VanderWerf).


You are right: it is best to leave these extensions out of trunk. I can 
maintain them separately.

However, some clarifications:

* the proposed #take_all and #replace_all operations do *not* block. 
They are like #read_all in that respect.

* #read_all is not one of the original Linda primitives, either, AFAICT. 
(Yet, I cannot imagine using linda/rinda without it :)

Thanks for all your excellent work on distributed ruby, Eric and 
Masatoshi. Cheers!

----------------------------------------
Feature #8128: New primitives for Rinda::TupleSpace
https://bugs.ruby-lang.org/issues/8128#change-37952

Author: vjoel (Joel VanderWerf)
Status: Rejected
Priority: Normal
Assignee: seki (Masatoshi Seki)
Category: lib
Target version:


=begin

= New primitives for Rinda::TupleSpace

This issue proposes adding two new primitives to TupleSpace for atomic 
bulk operations:

== 1. TupleSpace#replace_all

=== What it does

Calling

  replace_all(tuple, new_tuple, sec=nil)

atomically removes all tuples matching ((|tuple|)) and writes 
((|new_tuple|)). It does not block waiting for tuples. The return value 
is a pair:

  [ matching_tuples, entry ]

where ((|matching_tuples|)) is like the return value of 
(({read_all(tuple)})) and
((|entry|)) is like the return value of (({write(new_tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives. As 
noted in ((*The dRuby Book*)), p. 176, "It isn't easy to represent a 
dictionary using TupleSpace." Essentially, the #[]= and #[] operations 
must take/write a global lock tuple.

Using #replace_all, it is easy to implement a key-value store without 
lock tuples. See key-value-store.rb for an example.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the replace_all functionality.


=== Examples

See key-value-store.rb and example-replace-all.rb.


== 2. TupleSpace#take_all

=== What it does

Calling

  take_all(tuple)

atomically removes all matching tuples. It does not block waiting for 
tuples. The return value is the array of tuples, like the return value 
of (({read_all(tuple)})).


=== Why it is needed

It is not possible to do this atomically with existing primitives, 
though in this case atomicity may not be important. More importantly, it 
is not possible to do this efficiently with existing primitives. The 
best approximation would be an unbounded sequence of #take calls.


=== Modularity

The new code is entirely contained in two modules in a single separate 
file. These modules are included/extended to TupleSpace and 
TupleSpaceProxy as desired to add the take_all functionality.


=== Examples

See example-take-all.rb.

=end
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.