Mike's Tech Notes for 6/28/2012

Today I checked out the following sites and found them useful, so I thought I'd post about them for both my are your reference in the future...

CCR Coordination Primitives
Asynchronous programming is hard because there is no simple method to coordinate between multiple operations, deal with partial failure (one of many operations fail but others succeed) and also define execution behavior of asynchronous callbacks, so they don't violate some concurrency constraint. For example, they don't attempt to do something in parallel. The Concurrency and Coordination Runtime (CCR) enables and promotes concurrency by providing ways to express what coordination should happen. Plus, enforce the high level constraints between different code segments, all run due to some messages being received on ports.
ccr coordination primitivesasynchronous programming hard simple method coordinate between multiple operations deal partial failure one many fail others succeed define execution behavior asynchronous callbacks don't violate concurrency constraint example attempt something parallel runtime enables promotes providing ways express happen plus enforce high level constraints different code segments run due messages being received ports primitive thread spawn handler defined ccrservicebase couple additional overloads accept parameters pass lt t0 gt passes parameter type call times eventually use available threads free running amongst apart themselves it’s important realize relationship loose coupling fast initiation work consistent queues interaction software design scales well dependencies drawbacks mentioned above addressed appropriate model components primitives provided classified based two primary scenarios inbound requests long lived service oriented common web listening http network port post attaching handlers wake up serve each request independent addition uses advanced guarantee never active responses more outstanding possible return types per response waiting success portset associated pending completes item posted execute another scattering once collecting single caring order arrive arbiter described briefly followed detailed explanation context static classthe class provides helper routines creating instances classes discoverable safe manner methods below members exhaustive list arbiters constructed configurations directly constructor following shows created invoking fromtask creates instance taskarbiter choice choicearbiter receive receiverarbiter interleave interleavearbiter joinedreceive joinreceiverarbiter multipleitemreceive joinsingleportreceiverthe reference documentation used necessary extension methodsa concise alternative through new support examples guide extensions create receivers joins etc responseport easy way handle dss services expose portsets contain requested information fault whichever message sent back effectively waits same time executes corresponding delegate receives receivera receiver associates user takes persist option true false un register 7c var activate _taskqueue console writeline notice persisted until garbage collected abbreviated syntax anonymous statement called line print value experienced programmer older style â example 8c alternate version explicitly constructs passing factory persistedreceiver null predicate task exactly effect really thin wrapper around arbiterthe branches atomically step cant interrupted removes nested guarantees branch branching guard against race conditions 9c serviceport simpleservice getstate given found ex delegates note take arbitrary number receiversmultiple come categories known waitformultiple os literature attempts items wait try again right met phase logic deadlock mechanism atomic access resources without fear specified fixed compile fact join over forms typed eagerly remove participating total count satisfied very resource synchronization gathering results scatter gather joinsexample 10c portdouble portstring joined stringvalue tostring updated values matter power 14159 last 10 demonstrates activated posts determines everything needs schedules 11c portint second listen listens share contention intvalue 128 determine first allowing lost 11 previous showing case implementation both soon extracted shared races affect outcome basically traditional locking problem become scheduling dependency resolved guarded concurrent signal triggers requires 12c itemcount 12 dynamic â join stored variable read expected aggregate 13c exception requestcount send set respond failures successes 13 dealing assuming multipleitemreceiver gives arriving combination collections containing mutipleitemreceive discrete underlying multipleitemgather executed yield implicit activation need useâ arbiter inside iterator componentspersisted receiversccr motivated beginning capable efficiently executing process simplest mode whenever 14c summary base defines public serviceoperation stop updatestate state component abstract api _mainport dispatcherqueue _state taskqueue initialize private supplied three concurrently updatehandler getstatehandler external callers cache dispatcher queue schedule tasks demonstrate invalidoperationexception update field result itself 14 implementing pattern definitions interact definition derived accepts derive convenient reuse particular initializes returns communicate attaches talk exist arbiterfor non trivial carefully protected data structure internally requiring updates treated scenario complex multi preempted certain helps think care queueing activations complete declare protection require programmers familiar reader writer lock similar concept biased instead specific object sections avoiding internal manages exclusively 15c servicewithinterleave relation teardownreceivergroup teardown stophandler exclusivereceivergroup runs concurrentreceivergroup merge strings makes stopping 15 extends various parent youâ can concisely intent terms independently know exclusive protect later section steps writing subclass dsspservicebase automatically maininterleave furthermore added start mark servicehandler attribute see

How do you use the ScatterGather function?
The above code will fill resultPort with a bunch of zeroes. if I return i instead, it fills up with 0 through 9. This makes sense to me since the i variable is analagous to a for loop variable, and num appears to be some parameter passed in. I get zero since I didn't pass any in.
use scattergather function var resultport activate dispatcherqueue 10 num gt above code fill bunch zeroes return instead fills up through makes sense variable analagous loop appears parameter passed zero didn't pass expect p0 numbers possibly out order ten example 1144330022is output one execution

TPL Dataflow and async/await vs CCR - part 3 - Being Cellfish - Site Home
While you could use TPL data-flow for scatter/gather patterns in much the same way as CCR async/await is actually enough for you once again. The only thing you need to do is to create a number of tasks and then wait for them all either by using the Task.WaitAll method (or Task.WaitAny if you're only interested in the first result) but if you have a short constant list of tasks to wait for I would just wait for them with the await keyword like this:
tpl dataflow async await vs ccr part being cellfish site homewhile use data flow scatter gather patterns much same way actually enough once again thing need create number tasks wait task waitall method waitany you're interested first result short constant list keyword code formatted http manoli net csharpformat publicstatic lt gt fibonacciasync return var n1 n2 returnawait 10 remember common pattern want large success failure achieved depending report errors exceptions continue throw exception error occurs case returned flows suitable solution very ccrish done post back etc preventive comment technically above execute synchronously threads started real methods called important wanted show simple calling functions awaiting results needed

blog comments powered by Disqus

About the author

I'm a .NET, XAML, and iOS polyglot that loves playing with new things and making cool and innovative stuff.  I am also a Mac junkie.

I am Principal Technologist for SunGard Global Services in NYC, in their Advanced Technologies practice, and I work extensively with SunGard's energy and financial customers.

Note the the posting on this blog are my own and do not represent the position, strategies or opinions of SGS.

Widget TwitterFeed not found.

The file '/widgets/TwitterFeed/widget.ascx' does not exist.X

Recent Comments


Month List