80 likes | 189 Vues
This video lecture by Austin Lansing, dated March 5, 2011, delves into Io concurrency and coroutines. It covers essential concepts such as user-level threads and the Scheduler object, which manages the resumption and yielding of threads. Learn how Io can efficiently handle thousands of threads, utilizes asynchronous messages with actors, and implements futures for asynchronous operations. This guide also touches on interactive scripts and practical yield methods, providing a solid foundation for understanding Io's concurrency model.
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