80 likes | 184 Views
Midterm cps-5135g. Video: http://goview.com/goldwyn/spring/play?method=playRecording&recordingId=512318ec-f3ac-41e0-8f17-e477dd06db90 Io Concurrency ( Coroutines ) Author: Austin Lansing Date: March 5 th , 2011. Io Concurrency Definitions. Io Concurrency Coroutines Coroutines
E N D
Midterm cps-5135g Video: http://goview.com/goldwyn/spring/play?method=playRecording&recordingId=512318ec-f3ac-41e0-8f17-e477dd06db90 Io Concurrency (Coroutines) Author: Austin Lansing Date: March 5th, 2011
Io Concurrency Definitions • Io Concurrency Coroutines • Coroutines • User Level Threads (as opposed to OS Threads) • Reduces strain on System Resources • Io capable of processing thousands of threads • Reference: http://www.iolanguage.com/scm/io/docs/reference/index.html#/Core/Core/Coroutine • http://www.iolanguage.com/scm/io/docs/IoGuide.html#Concurrency
Scheduler • Scheduler Object • Responsible for resuming and yielding threads • Scheduler process threads as First Come First Serve • Scheduler yieldingCoros size = # of coroutines yielding • Reference • http://www.iolanguage.com/scm/io/docs/reference/index.html#/Core/Core/Scheduler • Try – Interactive Scripts (Scheduler)
Actors • Actors • Object with own thread (coroutine) • Actors coroutine is used to process asyncronous message • Io Asyncronous messages can be sent to any object using futurSend command(@) or asyncSend command (@@) • Object becomes actor when it receives asyncronous message
Io Concurrency - Futures • Futures • Send future to object using (@). • Futures return a value once asyncronous message completes • TRY IT – Interactive Scripts (Futures)
Yield and YieldCoros • Yield • yields control of Coroutine, so other Coroutines can run • cObjyieldMethod := method(for(a, 1,10, a println; yield)) • Scheduler yieldingCoros • List of yielding coroutines. • Use the list method size to get # of yielding coroutines • while(Scheduler yieldingCoros size > 0, yield) //releases yielding coroutines
Inspecting Io Concurrency Objects • Protos Core Coroutine • Protos Core CoroutineisActive • Protos Core Scheduler • Protos Core Scheduler yieldingCoros Also use IoLanguage.com reference http://www.iolanguage.com/scm/io/docs/reference/index.html#/Core
Putting it together - race.txt Script