wetware / pkg

Peer-to-peer cloud environment
https://wetware.run
Other
37 stars 7 forks source link

Implement single sender, single receiver synchronous channel #79

Closed evan-schott closed 1 year ago

evan-schott commented 1 year ago

Create implementation in wetware/ww/pkg/csp/basic.go by following the flow chart below. Use go channel to signal between receiver and sender, and lock to control access to sent value. Screen Shot 2023-02-06 at 11 05 55 AM

lthibault commented 1 year ago

Use go channel to signal between receiver and sender

Note that this is not a hard requirement. You might find it simpler to use a mutex to protect some fields, e.g.

type syncChan struct {
    mu sync.Mutex
    sendrReady, recvrReady bool
    value capnp.Ptr  // the value being transferred from sender to recver
}

(Then again, maybe the channel is actually easier. Your call.)

lthibault commented 1 year ago

https://hackmd.io/@fCsHyW7yR3C5lGQFbh9KdQ/BkiAsWeTs

☝️ POC implementation using sync.Cond + important notes about correctness.

lthibault commented 1 year ago

Closing per #88