advertisement

CSP: Huh? And Components

60 %
40 %
advertisement
Information about CSP: Huh? And Components
Technology

Published on March 7, 2014

Author: DanielFagnan

Source: slideshare.net

advertisement

CSP: Huh? And Components @TheHydroImpulse hydrocodedesign.com github.com/TheHydroImpulse

Communicating Sequential Processes

• I won’t be getting into the complex theory. • I’ll be going into the practical examples of CSP.

Concurrency What is it exactly?

Concurrency != Parallelism • • • Concurrency is a model for concurrent execution. Parallelism is the literal act of being concurrent. With concurrency, tasks are able to run at the same time, but they don’t have to — that’s parallelism.

CSP: Huh? • A formal language for describing patterns of interaction in concurrent systems. • based on message passing via channels.

Channels • A powerful primitive for communication • Channels are exactly what you think it is; they let you pass stuff through it. • Two basic actions: Put & Take Input Channel Output

Kinds of Channels Buffered Unbuffered (Can be dangerous)

Basic Actions • Put: Send a new value onto the channel • Take: Receive on existing value from the channel.

Channel Semantics • Semantics vary on the language/implementation. • The basic semantics are: • on share-ability of concrete channels. (i.e., across tasks/threads?) • when channels block

Blocking • Can block when trying to put a value onto the channel when it’s full. • Can block when trying to take a value from an empty channel.

What Blocks? • Very much dependent on the implementation/language. • Golang blocks on goroutines (a.k.a green threads) • Rust blocks on tasks (a.k.a green threads or native threads) • Clojure (core.async): both actions have the potential to block the underlying thread.

Clojure: core.async • A library not a language feature. • Goes to show how powerful a consistent language form (Lisp) can be, thanks to macros. • Supports unbounded buffered and bounded buffered channels. The former is discouraged. • Two implementations of the underlying “threads”. • Supports timeouts (super powerful) • All operations are expressions not statements. • Priority selects with alts!

Clojure: core.async • Supports two kinds of thread of control: • • • IoC (inversion of control) Normal Threads IoC threads are created with go blocks • go is a macro that examines it’s body for any channel operations and turns them into a state machine. • C#’s async does the same thing.

Clojure: Example!

JavaScript Example! • Uses ES6 Generators • Similar to ClojureScript/Clojure’s go blocks.

Callbacks (Direct Data-Flow) • Worst style of concurrency • You have no control over the data flow. • You’re (the callback) at the mercy of the caller.

Direct vs Indirect Direc t In Callback/Logic Out Indirec t In Channel Logic Channel Out

Indirect = Channels • Channels offer a better alternative at managing data-flow. • They are indirect. This means the logic is in control of the data-flow. • The logic can decide when it’s had too much data coming through. It’s the best decider at judging how much it can handle.

Examples! • Return the 5 fastest search queries. • Return the x number of queries that finish within 3 seconds (timeouts) • Channels act like queues. They’re a buffer for your data.

Components Building modular applications.

Components • Not an abstract component. • https://github.com/component/component • A client-side package manager and build tool. • CommonJS style code. • Ability to share client and server code super easily.

Unix Style • Build small, concentrated applications that do one thing, and does that thing extremely well. • Modular • Modular • Modular

Globals..grrr • Globals are horrible. Never use them. • Globals are horrible. Never use them. • Globals are horrible. Never use them. • jQuery, Angular, Ember, etc… ALL use them.

/** * Module Dependencies */ var dom = require('dom'); var model = require('tower-model'); var migration = require('tower-migration'); /** * User Model */ model('user') .attr('email') .validate('presence') .validate('isEmail') .attr('firstname') .attr('lastname') .attr('country') .attr('city'); /** * Migration */ migration.up('create_user_table') .model('user');

Creating a Component App

Modular Apps • It’s the future • Building monolithic apps suck • Tooling is only going to get better. • It’s much easier to wrap your head around a single module that has no side-effects (i.e., no external state & globals).

Server & Client-side • Node.js offers the ability to share code with the client-side (components). • Both have the same module pattern (CommonJS • Module can now be designed for both platforms.

No Globals? • We can take advantage of the module caching. • A version of inversion-of-control • Decentralized.

Module Caching • If each module is concentrated, you can store data (instances, values, etc…) in the module exports or module itself. • Example!

Wrapping Up • CSP is awesome. • Clojure is awesome. • Message passing & channels are awesome. • Modular apps are awesome. • Globals are horrible. • Callbacks are horrible.

Resources

Components & ES6 • Module system in ES6 replaces the build system in component. • Components might just become a package manager.

Thanks! @TheHydroImpuls e github.com/TheHydroImpulse hydrocodedesign.co m

Add a comment

Related presentations

Presentación que realice en el Evento Nacional de Gobierno Abierto, realizado los ...

In this presentation we will describe our experience developing with a highly dyna...

Presentation to the LITA Forum 7th November 2014 Albuquerque, NM

Un recorrido por los cambios que nos generará el wearabletech en el futuro

Um paralelo entre as novidades & mercado em Wearable Computing e Tecnologias Assis...

Microsoft finally joins the smartwatch and fitness tracker game by introducing the...

Related pages

CSP developmentin Italy - ΑΚΑΔΗΜΙΑ ΑΘΗΝΩΝ

CSP developmentin Italy Workshop ... Components for CSP plants ... (H(H 2O) I (H Activities on thermochemicalcycles.
Read more

QUARZ - DLR Portal - DLR

QUARZ Test and ... †H †H † † † Parabolic ... for components of CSP plants, developed and operated by experienced scientific staff of the DLR ...
Read more

Installing New Cryptographic Service Providers | The ...

Installing New Cryptographic Service Providers ... huh? AET evidently think ... Only the CSP components need to be installed on other machines.
Read more

16.Hrd Audit-basic,Concept and Components - Documents

16.Hrd Audit-basic,Concept and Components Nov 18, 2014 Documents vishal. of 3 ... CSP: Huh? And Components. Login or Join. Processing Login successful.
Read more

Concentrating Solar Power Technologies - INEMI

Concentrating Solar Power Technologies. Dr. Raed Sherif. ... H H H H H H H H H H H H ... Traditional CSP requires intensive field construction –cranes ...
Read more

www.scribd.com

81536 v2. Development of Local Supply Chain: The Missing Link for Concentrated Solar Power Projects in India ESMAP MISSION The Energy Sector Management ...
Read more

2014 12 16 R&D on CSP and Solar Chemistry in Europe

R&D on CSP and Solar Chemistry in Europe International Workshop on R&D, and EDUCATION for NEXT GENERATION SOLAR HYDROGEN ENERGY SYSTEM Niigata University ...
Read more

SECTION A MOTORS AND ELECTRICAL COMPONENTS TOPICS

SECTION A MOTORS AND ELECTRICAL COMPONENTS TOPICS ... T h h = ___ (T c + K) - K R c Th = Temperature hot Tc = Temperature cold Rh = Resistance hot (ohms)
Read more