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

Blocking Across The Wire

Blocking Across The Wire

If you're writing high-performance async code, blocking is the worst thing you can do, right? Except, what if blocking on remote (across the wire) processes is exactly what you want to do!?

CSP (Communicating Sequential Processes) is a channel-based async concurrency pattern that's built on "blocking" semantics. This talk is a wild experiment into upending and rethinking asynchronous programming. We'll explore practical applications of CSP in JS and then look at how we can extend it to work across the wire between browser and server.

Kyle Simpson

November 15, 2015
Tweet

More Decks by Kyle Simpson

Other Decks in Programming

Transcript

  1. kyle simpson @getify http://getify.me
    blocking across
    the wire

    View full-size slide

  2. 1
    2
    3
    4
    1
    2
    3 done!
    done!

    View full-size slide

  3. coordination

    View full-size slide

  4. synchronous
    async

    View full-size slide

  5. *caveat emptor
    generators + promises

    View full-size slide

  6. *caveat emptor
    generators + promises
    ?

    View full-size slide

  7. *caveat emptor
    *
    s

    View full-size slide

  8. CSP
    content security policy
    communicating sequential
    processes

    View full-size slide

  9. CSP: go, cljs
    @swannodette
    @jlongster

    View full-size slide

  10. channel-based
    concurrency

    View full-size slide

  11. channel: stream
    with buffer=1
    back pressure

    View full-size slide

  12. github.com/getify/a-tale-of-three-lists

    View full-size slide

  13. asynquence
    github.com/getify/asynquence

    View full-size slide

  14. ...across the
    wire!?
    blocking...
    (localized)

    View full-size slide

  15. server
    client

    View full-size slide

  16. remote channel
    github.com/getify/remote-csp-channel
    *extremely alpha
    does NOT require asynquence

    View full-size slide

  17. one last thing

    View full-size slide

  18. ...across all
    the threads!
    blocking...

    View full-size slide

  19. yep. multi-threading.
    in javascript.

    View full-size slide

  20. browser-web worker
    browser-browser
    browser-server
    server-child process
    ...

    View full-size slide

  21. CSP is a powerful,
    simple pattern for
    distributed,
    coordinated concurrency

    View full-size slide

  22. thanks!
    kyle simpson @getify http://getify.me

    View full-size slide