Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Concurrent Revisions

Concurrent Revisions

A Scala implementation of the “Concurrent Programming with Revisions and Isolation Types” paper.

Presented at the North East Scala Symposium, New York NY, 2014 http://nescala.org/

Daniel James

March 02, 2014
Tweet

More Decks by Daniel James

Other Decks in Programming

Transcript

  1. Sebastian Burckhardt, Alexandro Baldassion, and Daan Leijen. Concurrent Programming with

    Revisions and Isolation Types. In Proceedings of the ACM International Conference on Object Oriented Programming Systems Languages and Applications (OOPSLA’10), ACM SIGPLAN, Reno, NV, October 2010 Daan Leijen, Sebastian Burckhardt, and Manuel Fahndrich. Prettier Concurrency: Purely Functional Concurrent Revisions. In Haskell Symposium 2011 (Haskell’11), ACM SIGPLAN, Tokyo, Japan, 7 July 2011 Disclosure: not my work!
  2. val v = VersionedValue(0) val r = Revision.fork { assert(v.value

    === 0) v.value = 1 } assert(v.value === 0)
  3. val v = VersionedValue(0) val r = Revision.fork { assert(v.value

    === 0) v.value = 1 } assert(v.value === 0) Revision.join(r) assert(v.value === 1)
  4. val v = VersionedValue(0) val r = Revision.fork { assert(v.value

    === 0) v.value = 1 } v.value = 2 assert(v.value === 2)
  5. val v = VersionedValue(0) val r = Revision.fork { assert(v.value

    === 0) v.value = 1 } v.value = 2 assert(v.value === 2) Revision.join(r) assert(v.value === 1)
  6. val v = CumulativeValue(1, addMerge) val r = Revision.fork {

    assert(v.value === 1) v.value += 2 } v.value += 3
  7. val v = CumulativeValue(1, addMerge) val r = Revision.fork {

    assert(v.value === 1) v.value += 2 } v.value += 3 assert(v.value === 4)
  8. val v = CumulativeValue(1, addMerge) val r = Revision.fork {

    assert(v.value === 1) v.value += 2 } v.value += 3 assert(v.value === 4) Revision.join(r) assert(v.value === 6)
  9. val x = VersionedValue(0) val y = VersionedValue(0) val r

    = Revision.fork { if (x.value == 0) y.value += 1 } if (y.value == 0) x.value += 1 Revision.join(r) assert(x.value === ???) assert(y.value === ???)
  10. x = 0 y = 0 if(y==0) x++ assert((x==0 &&

    y==1) || (x==1 && y==0) || (x==1 && y==1)) if(x==0) y++ sequential consistency
  11. x = 0 y = 0 lock.synchronized { if(y==0) x++

    } assert((x==0 && y==1) || (x==1 && y==0)) lock.synchronized { if(x==0) y++ } mutex lock
  12. x = 0 y = 0 atomic { if(y==0) x++

    } assert((x==0 && y==1) || (x==1 && y==0)) atomic { if(x==0) y++ } transactional memory
  13. x = 0 y = 0 if(y==0) x++ assert(x==1 &&

    y==1) if(x==0) y++ concurrent revisions