Skip to content
This repository has been archived by the owner on Nov 10, 2017. It is now read-only.

LinkedSparseMatrix thread safe set #44

Closed
fommil opened this issue Feb 3, 2014 · 5 comments
Closed

LinkedSparseMatrix thread safe set #44

fommil opened this issue Feb 3, 2014 · 5 comments

Comments

@fommil
Copy link
Owner

fommil commented Feb 3, 2014

it would be great to be able to do parallel sets, and then effectively do streaming adjacency matrix construction as part of an Observable/RX pattern.

@fommil
Copy link
Owner Author

fommil commented Feb 3, 2014

this is incredibly non-trivial...

@fommil
Copy link
Owner Author

fommil commented Feb 3, 2014

hmm, to be able to use locks I think we'd need to have nodes for all the zeroeth rows and colums, i.e. a memory cost of N + M for an NxM matrix. I might create Scala feasibility of this in a scratch area.

@rorygraves
Copy link

You can do it with far fewer locks - you use a master lock to obtain lock instances.
Create two methods e.g.:

class LockController {
  def aquire(n : Int,m : Int) : (Lock,Lock) = synchronized {
     // we are in a guardian lock we can create new locks for N or M as needed.
  }

  def release(nLock : Lock,mLock : Lock) = synchronized {
    // we are in the guardian lock - assuming no more holder we can free locks as we feel.
  }
}

Obviously the N/M locks could be returned as a pair with aquire/release logic to ensure correctness.

This way you can reuse a very small number of locks,which approximates your row contention ratio rather than tracking NxM

@fommil
Copy link
Owner Author

fommil commented Feb 3, 2014

main problem is that I need to rethink the structure to facilitate row/column locks. The current structure is not limited to a row or column :-/ writing tests for the new structure as we type...

@fommil
Copy link
Owner Author

fommil commented Apr 12, 2014

giving up on this... too complicated!

@fommil fommil closed this as completed Apr 12, 2014
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants