Download presentation
Presentation is loading. Please wait.
Published byJodie Banks Modified over 9 years ago
1
George Chrysanthakopoulos Software Architect Microsoft Corporation
4
Coordination and Concurrency runtime (CCR) Decentralized Software Services (DSS) Visual Programming Language Visual Configuration and Deployment Visual Studio templates Samples and tutorials Infrastructure services
5
Event processing for security systems Mail sorting system ASP.NET page handling, IO coordination
15
Dispatcher Port Dispatcher Queues Threads Arbiter Handler Arbiter is attached to port Arbiter is activated on queue Dispatcher schedules items from its queues round-robin to run in its threads Post places a message on the port Arbiter checks whether it can consume the message Creates work item from message and handler Creates work item from message and handler Enqueue work item Thread calls handler with message as arg Scheduler picks next work item to execute
16
Handler Dispatcher Port Dispatcher Queues Threads Arbiter Handler There can be many of everything
17
Single-Port Primitives Code-Scheduling (non port-specific) Multi-Port Primitives
18
var dispatcher = new Dispatcher(0,”default”); var queue = new DispatcherQueue(dispatcher); var port = new Port (); port.Post("Hello, World!"); Arbiter.Activate(queue, port.Receive(message => Console.WriteLine(message) ) ); Port: Building block for sending and receiving messages Post: Queues a message Task: Delegate that handles the message (message is consumed) Receive coordination primitive Dispatcher uses fixed number of threads, schedules from queues in round-robin Port on which to receive the message
19
void Start() { var queue = new DispatcherQueue(); var port = new Port (); port.Post("Hello"); port.Post(“World”); Arbiter.Activate(queue, new IterativeTask(() => Hello(port) ) ); } IEnumerator Hello(Port port) { for(var i=0; i<5; i++) { yield return port.Receive(); var message = (string)port; Console.WriteLine(message); } Schedule iterative task Lambda captures arguments for iterator Yield execution until receive is satisfied Item retrieved after yield Loops around asynchronous operations are easy
20
IEnumerator CcrReadFileAsync(string file) { var result = new Port (); using (var fs = new FileStream(file,…,FileOptions.Asynchronous)) { var buf = new byte[fs.Length]; fs.BeginRead(buf, 0, buf.Length, result.Post, null); yield return result.Receive(); var ar = (IAsyncResult)resultPort.Test(); try { fs.EndRead(ar); ProcessData(buf); } catch { // handle exception } } Instead of passing a delegate, stream will post AR to port Retrieve AR result from port Complete operation
21
static IEnumerator CopyStream(Stream source, Stream dest) { var buffer = new byte[4096]; int read = 0; do { PortSet readResult = StreamAdapter.Read( source, buffer, 0, buffer.Length); yield return readResult.Choice(); var exception = (Exception)readResult; if (exception != null) yield break; read = (int)readResult; var writeResult = StreamAdapter.Write(buffer,0,read); yield return writeResult.Choice(); } while (…) } CCR Adapter for Stream class Yield to result outcomes Retrieve success outcome (bytes read) Proceed to asynchronous write
25
Microsoft Open Specification Promise
26
<DriveState true 0.112 … … 80 2007-10-10T13:07:45.5195866-07:00 Flexible UI Service Orchestration
29
[DataContract] class State { [DataMember] public List {get; set;} } [DataContract] class Record { [DataMember] public string Name {get; set;} [DataMember] public int Age{get; set;} } // operation class Query : Query {} // operation port class OperationsPort : PortSet {}
30
[Contract(Contract.Identifier)] class RecordKeeperService : DsspServiceBase { [Partner(“PeopleLookup”, Policy = PartnerCreationPolicy.UseExistingOrCreate, Optional = false)] peopleLookup.OperationsPort _peopleLookupPort = peopleLookup.OperationsPort(); [ServicePort(“/recordkeeper”,AllowMultipleInstances = true] OperationsPort _mainPort; protected override void Start() { base.Start(); } Declarative, dynamic composition, annotations picked up by visual editor Attach handlers to operation port, publish instance URI in service directory
31
[ServiceHandler(ServiceHandlerBehavior.Concurrent)] public IEnumerator QueryHandler(Query queryOp) { var response = FindItem(queryOp.Body); queryOp.ResponsePort.Post(response); yield break; } [ServiceHandler(ServiceHandlerBehavior.Exclusive)] public IEnumerator UpdateHandler(Update updateOp) { QueryAge queryAgeOp; yield return _peopleLookupPort.Query(out queryAgeOp); int age = (int) queryAgeOp.ResponsePort; UpdateRecord(age, updateOp.Body.Name); updateOp.ResponsePort.Post(new UpdateResponse()); } CCR Interleave is iterator-aware, guaranteeing atomicity across asynchronous steps
32
Create causality at root of execution graph Failure occurs on one of the side branches Deal with error as message at origin of execution
35
Available DSS services Request Notification Response Service instance
41
Please fill out your evaluation for this session at: This session will be available as a recording at: www.microsoftpdc.com
43
© 2008 Microsoft Corporation. All rights reserved. Microsoft, Windows, Windows Vista and other product names are or may be registered trademarks and/or trademarks in the U.S. and/or other countries. The information herein is for informational purposes only and represents the current view of Microsoft Corporation as of the date of this presentation. Because Microsoft must respond to changing market conditions, it should not be interpreted to be a commitment on the part of Microsoft, and Microsoft cannot guarantee the accuracy of any information provided after the date of this presentation. MICROSOFT MAKES NO WARRANTIES, EXPRESS, IMPLIED OR STATUTORY, AS TO THE INFORMATION IN THIS PRESENTATION.
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.