Polyphonic C - PowerPoint PPT Presentation

1 / 1
About This Presentation
Title:

Polyphonic C

Description:

Client makes multiple async requests and later blocks until all ... x.wait(i,j); // do something with i and j. http://research.microsoft.com/~nick/polyphony ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 2
Provided by: andrewk89
Category:

less

Transcript and Presenter's Notes

Title: Polyphonic C


1
Polyphonic C
MSR CambridgeProgramming Principles Tools
Here's how to provide methods for obtaining and
releasing either exclusive (for writing), or
shared (for reading), access to a resource
delegate async IntCB(int v) class Service
public async request(String arg, IntCB cllbck)
// do some work cllbck(result)
  • class ReaderWriter
  • public void Exclusive() async Idle()
  • public void ReleaseExclusive() Idle()
  • public void Shared() async Idle() S(1)
  • public void Shared() async S(int n)
    S(n1)
  • public void ReleaseShared() async S(int n)
  • if (n 1) Idle() else S(n-1)
  • public ReaderWriter() Idle()

class Join2 void wait(out int i, out int j)
async first(int r1) async second(int r2)
i r1 j r2 return // client
code int i,j Join2 x new Join2() service1.req
uest(arg1, new IntCB(x.first)) service2.request(a
rg2, new IntCB(x.second)) // do something
useful // now wait until both results have come
back x.wait(i,j) // do something with i and j
Notes
State is kept in a single private message none
?? Idle() ?? S(1) ?? S(2) ?? S(3) If, for
example, a thread has called Exclusive() on a new
ReaderWriter(), subsequent calls of Shared() from
other threads will block until ReleaseExclusive()
is called. A second call to Exclusive() will then
block until a matching number of ReleaseShared()
messages have been received.
Chords
http//research.microsoft.com/nick/polyphony
Write a Comment
User Comments (0)
About PowerShow.com