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
PRO

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 Slide

  2. concurrency

    View Slide

  3. async

    View Slide

  4. View Slide

  5. event loop

    View Slide

  6. 1
    2
    3
    4
    1
    2
    3

    View Slide

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

    View Slide

  8. parallel

    View Slide

  9. View Slide

  10. coordination

    View Slide

  11. View Slide

  12. View Slide

  13. synchronous
    async

    View Slide

  14. generator

    View Slide

  15. *caveat emptor
    generators + promises

    View Slide

  16. *caveat emptor
    generators + promises
    ?

    View Slide

  17. *caveat emptor
    *
    s

    View Slide

  18. generators

    View Slide

  19. View Slide

  20. View Slide

  21. CSP
    content security policy
    communicating sequential
    processes

    View Slide

  22. CSP: go, cljs
    @swannodette
    @jlongster

    View Slide

  23. channel-based
    concurrency

    View Slide

  24. View Slide

  25. channel: stream
    with buffer=1
    back pressure

    View Slide

  26. blocking...

    View Slide

  27. View Slide

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

    View Slide

  29. View Slide

  30. asynquence
    github.com/getify/asynquence

    View Slide

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

    View Slide

  32. server
    client

    View Slide

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

    View Slide

  34. one last thing

    View Slide

  35. ...across all
    the threads!
    blocking...

    View Slide

  36. wait. what?

    View Slide

  37. yep. multi-threading.
    in javascript.

    View Slide

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

    View Slide

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

    View Slide

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

    View Slide