際際滷

際際滷Share a Scribd company logo
ASYNCHRONOUS
PROGRAMMING
    FTW!
    (SAWYER X)
DOES THIS SOUND FAMILIAR?
               "Hi"
            "Hi, dad"
         "Got a minute?"
              "Yes"
     "I'm looking for a movie
        Where do I start?"
    "Go to the cinema website"
      "What's the address?"
 "www.whatchamacallit.whatever"
          "Just a sec..."
...
...
...
...
"Well?"
"Ah! It loaded! What now?"
  "Click on new movies"
         "OK..."
           ........
         "Well?"
        "Loading"
    *sounds of clicks*
"OK, now what?"
      "Find a movie you want"
            "Then what?"
"Click on it, you'll have instructions"
        * eternity passes by *
             "WELL?!?"
     "Just a sec... it's loading..."
          /me shoots myself
ILLUSTRATED
          (USING WWW::MECHANIZE)
$eh>e(cnm_r)
 mc足gt$ieaul余
i油油mc足sces){
 f($eh>ucs油油
油油$eh>lc(NwMve'余
 油油mc足cik'e油ois)
油油i油油mc足sces){
 油油f($eh>ucs油油
油油油油m油mve油油mc足fn_nus..
 油油油油y@ois=$eh>idipt(.)
油油}
 油油
}
LET'S TRY THIS AGAIN...
                 "Hi"
               "Hi, dad"
            "Got a minute?"
                 "Yes"
        "I'm looking for a movie
           What should I do?"
"Go to this website, click on new movies
  Then pick a movie, and click on it"
             "Thank you"
           "You're welcome"
GREAT SUCCESS!
CALLBACKS
        Reference to a code
        Passed as an argument
        Can be called by some other code
sbtysmtig{
 u油r_oehn油
油油m油ipt油油hf余
 油油y$nu油=sit
油油m油c油油油油hf余
 油油y$b油油=sit
油油m油rsl油油oeoeain$nu)
 油油y$eut=sm_prto(ipt余

油油i油油rsl足{sau'油q'K油油
 油油f($eut>'tts}e油O'){
油油油油$b>油rsl足{cnet})
 油油油油c足($eut>'otn'油余
油油}
 油油
}

tysmtig油sm油admipt,sb{
 r_oehn("oerno油nu"油u油
油油m油cnet=sit
 油油y$otn油油hf余
油油sy"ucsflrqetsy油cnet"
 油油a油Scesu油eus油as$otn!余
})
 油余
ILLUSTRATED, ASYNC
          (USING WWW::MECHANIZE)
$eh>e($ieaul油u油
 mc足gt油cnm_r,sb{
油油$eh>lc('e油ois,sb{
 油油mc足cik油NwMve'油u油
油油油油$eh>idipt(..油u油油y@ois=@油油
 油油油油mc足fn_nus油.,sb{m油mve油油_})
油油})
 油油油余
})
 油余
WHY IS THIS USEFUL?
Allow others to decide if something is good or not
m油jn油油uo>e(
 y$uo=Jn足nw
油油hss油>[w11112222]
 油油ot油=油q<...油...>,
油油cek油>{
 油油hcs=油
油油油油Fig=油
 油油油油Pn油>{
油油油油油油o_ucs油>sb{
 油油油油油油nsces=油u油
油油油油油油油油m油油jn,$ot油dt油油油_
 油油油油油油油油y($uo油hs,$aa)=@余
油油油油油油油油m油油i,$os油ag)=$uo>nlz_igrsl(
 油油油油油油油油y($p油ls,$v油油油jn足aayepn_eut
油油油油油油油油油油$aa>'ter}
 油油油油油油油油油油dt足{sdr',
油油油油油油油油)
 油油油油油油油油余

油油油油油油油油$ef>e_ot油hs,$v油余
 油油油油油油油油sl足sths($ot油ag)
油油油油油油}
 油油油油油油,

油油油油油油o_al=油u油
 油油油油油油nfi油>sb{
油油油油油油油油m油油jn,$ot)=@余
 油油油油油油油油y($uo油hs油油油_

油油油油油油油油$ef>eeehs(hs)
 油油油油油油油油sl足dlt_ot$ot余
油油油油油油}
 油油油油油油,
油油油油}
 油油油油
油油}
 油油
)余
WHY IS THIS USEFUL?
Allow others to decide if something is good or not
Allow easy stepping
Algorithm::Diff::Callback
ueAgrtm:if:alakq<ifary油ifhse>
 s油loih:Df:Clbc油wdf_rasdf_ahs余

df_ras
 ifary(
油油odfml_ebr,
 油油@l_aiymmes
油油nwfml_ebr,
 油油@e_aiymmes
油油sb{pit'ap油oha油bu油,sit}
 油油u油油rn油Hpyt油eraot'油hf油,
油油sb{pit'or油oha油bu油,sit}
 油油u油油rn油Sryt油eraot'油hf油,
)余

df_ahs
 ifhse(
油油oddtis
 油油%l_eal,
油油nwdtis
 油油%e_eal,
油油sb{sy'ot'油油hf油,
 油油u油油a油Ls油,油sit}
油油sb{sy'and'油hf油,
 油油u油油a油Gie油,sit}
油油sb{
 油油u油
油油油油m油油ky油bfr,$fe油油油_
 油油油油y($e,$eoe油atr)=@余
油油油油sy"kycagdfo油bfr油o$fe"
 油油油油a油$e油hne油rm$eoet油atr余
油油}
 油油,
)余
WHY IS THIS USEFUL?
Allow others to decide if something is good or not
Allow easy stepping
Allow control by other process (a type of IOC)
Allow asynchronous code
THE EVENT LOOP
Create loop
Register events
Run them
Let the user keep registering new events
m油eet油油..余
 y%vns=(.)

wie(){
 hl油1油
油油frahm油eet(ky油eet油油
 油油oec油y$vn油油es%vns){
油油油油$vn足(余
 油油油油eet>)
油油}
 油油
}
m油eet余%vns=(.)
 y%vns油eet油油..余

wie(){
 hl油1油
油油frahm油eet(ky油eet油油
 油油oec油y$vn油油es%vns){
油油油油$vn足(余
 油油油油eet>)
油油}
 油油
}

wie(){
 hl油1油
油油frahm油eet(ky油eet油油
 油油oec油y$vn油油es%vns){
油油油油i油油eet{eet{tm'油=tm油油
 油油油油f($vns$vn}'ie}<油ie){
油油油油油油$vns$vn}'oe}>)
 油油油油油油eet{eet{cd'足(余
油油油油}
 油油油油
油油}
 油油
}

sbadeet{
 u油d_vn油
油油m油油tm,$oe)=@余
 油油y($ie油cd油油油_
油油$vns$d{tm'油油tm余
 油油eet{i}'ie}=$ie
油油$vns$d{cd'油油cd余
 油油eet{i}'oe}=$oe
油油$d+
 油油i+余
}
EVENT TYPES
Timers (one-time, recurring, sleep replacement)
I/O (input output, including networking)
FUCK TALK
LET'S GO PROGRAMMING
IO::ASYNC
Loop interface: IO::Async::Loop
You can connect to hosts using it
You can add listeners to it (handles, sockets, etc.)
Explicitly call "run" when ready
ueI:Ayc:tem
 s油O:sn:Sra余
ueI:Ayc:op
 s油O:sn:Lo余
油
m油lo油油O:sn:Lo足nw
 y$op=I:Ayc:op>e余

$op>onc(
 lo足cnet
油油hs油油油=油sm.te.ot,
 油油ot油油油>"oeohrhs"
油油srie油=油24,
 油油evc油油>135
油油sctp油=油sra'
 油油okye油>'tem,
油油
油油o_tem=油u油油.油,
 油油nsra油>sb{..}
油油
油油o_eov_ro油>sb{
 油油nrsleerr=油u油
油油油油de"antrsle足$[1"
 油油油油i油Cno油eov油油_足]
油油}
 油油,

油油o_onc_ro油>sb{
 油油ncneterr=油u油
油油油油de"antcnet足$[]fie油_足]
 油油油油i油Cno油onc油油_0油ald$[1"
油油}
 油油,
)余

$op>u余
 lo足rn
o_tem=油u油
 nsra油>sb{
油油m油油sra油油油_
 油油y($tem)=@余

油油$tem>ofgr(
 油油sra足cniue
油油油油o_ed=油u油
 油油油油nra油>sb{
油油油油油油m油油sl,$ufe,$o油油油_
 油油油油油油y($ef油bfrf油ef)=@余

油油油油油油wie油{bfrf油~s^.)/){
 油油油油油油hl($$ufe}=油/(*n/油油
油油油油油油油油sy"eevdaln油1余
 油油油油油油油油a油Rcie油油ie$"
油油油油油油}
 油油油油油油

油油油油油油rtr油余
 油油油油油油eun0
油油油油}
 油油油油
油油)
 油油余

油油$tem>rt(A油nta油iehr'余
 油油sra足wie'niiilln油ee)

油油$op>d(sra)
 油油lo足ad$tem余
}
ANOTHER EXAMPLE
$pr油MO:sn油Me:Ayc:TP足油
 油el足I:Ayc足Nt:sn:HT油E'
油油I:Ayc>d(m油ht油油e:Ayc:TP>e油余
 油油O:sn足ad油y$tp=Nt:sn:HT足nw)
油油syfrI:Ayc>wi_l(mp{$tp>e(_油油)
 油油a油o油O:sn足aatal油a油油ht足gt$)}油
'>ls足fUL.x
 油油ito足Rstt


         Oh hai parallel HTTP GET!
POE
Loop interface: POE::Kernel
Runs "sessions" (POE::Session)
Each session is a context of events
Each session has an ID and heap
Call events in a current or different session
Explicitly call POE::Kernel->run when ready
POE
uePE油#At足nldsPE:enladPE:eso.
 s油O余油油uoicue油O:Kre油n油O:Ssin

#..dfn油alak油us(etsie油.
 油.油eieclbcssb油nx油ld)..

fr(.1){
 o油1.0油
油油PE:eso足cet(
 油油O:Ssin>rae
油油油油iln_tts=油
 油油油油niesae油>{
油油油油油油_tr油油=油&ade_tr,
 油油油油油油sat油油>hnlrsat
油油油油油油iceet=油&ade_nrmn,
 油油油油油油nrmn油>hnlriceet
油油油油油油_tp油油=油&ade_tp
 油油油油油油so油油油>hnlrso,
油油油油}
 油油油油
油油)
 油油余
}

PE:enl>u(余
 O:Kre足rn)
sbhnlrsat{
 u油ade_tr油
油m油油kre,$ep油ssin)=@[KRE,HA,SSIN]
 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余
油sy"eso油,$eso足I,"hssatd余
 油a油Ssin"油ssin>D油油a油tre"
油$ep>'on'油油余
 油ha足{cut}=0
油$enl>il(iceet)
 油kre足yed'nrmn'余
}

sbhnlriceet{
 u油ade_nrmn油
油m油油kre,$ep油ssin)=@[KRE,HA,SSIN]
 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余
油sy"eso油,$eso足I,"cutdt油,+$ep>'on'余
 油a油Ssin"油ssin>D油油one油o"油+ha足{cut}
油$enl>il(iceet)i油ha足{cut}<1余
 油kre足yed'nrmn'油f$ep>'on'油油0
}

sbhnlrso油
 u油ade_tp{
油sy"eso油,$[ESO]>D油油a油tpe"
 油a油Ssin"油_SSIN足I,"hssopd余
}
sbhnlrsat{
 u油ade_tr油
油m油油kre,$ep油ssin)=@[KRE,HA,SSIN]
 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余
油sy"eso油,$eso足I,"hssatd余
 油a油Ssin"油ssin>D油油a油tre"
油$ep>'on'油油余
 油ha足{cut}=0
油$enl>il(iceet)
 油kre足yed'nrmn'余
}
sbhnlriceet{
 u油ade_nrmn油
油m油油kre,$ep油ssin)=@[KRE,HA,SSIN]
 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余
油sy"eso油,$eso足I,"cutdt油,+$ep>'on'余
 油a油Ssin"油ssin>D油油one油o"油+ha足{cut}
油$enl>il(iceet)i油ha足{cut}<1余
 油kre足yed'nrmn'油f$ep>'on'油油0
}
sbhnlrso油
 u油ade_tp{
油sy"eso油,$[ESO]>D油油a油tpe.n余
 油a油Ssin"油_SSIN足I,"hssopd"
}
fr(.1){
 o油1.0油
油油PE:eso足cet(
 油油O:Ssin>rae
油油油油iln_tts=油
 油油油油niesae油>{
油油油油油油_tr油油=油&ade_tr,
 油油油油油油sat油油>hnlrsat
油油油油油油iceet=油&ade_nrmn,
 油油油油油油nrmn油>hnlriceet
油油油油油油_tp油油=油&ade_tp
 油油油油油油so油油油>hnlrso,
油油油油}
 油油油油
油油)
 油油余
}
PE:enl>u(余
 O:Kre足rn)
MORE CONDENSED
uePE
 s油O余

fr(.1){
 o油1.0油
油油m油cut=0
 油油y$on油油余

油油PE:eso足cet(
 油油O:Ssin>rae
油油油油iln_tts=油
 油油油油niesae油>{
油油油油油油_tr油油=油u油
 油油油油油油sat油油>sb{
油油油油油油油油sy"eso油,$[ESO]>D油油a油tre"
 油油油油油油油油a油Ssin"油_SSIN足I,"hssatd余
油油油油油油油油PE:enl>il(iceet)
 油油油油油油油油O:Kre足yed'nrmn'余
油油油油油油}
 油油油油油油,
油油油油油油iceet=油u油
 油油油油油油nrmn油>sb{
油油油油油油油油PE:enl>il(iceet)i油+cut<1余
 油油油油油油油油O:Kre足yed'nrmn'油f+$on油油0
油油油油油油油油sy"eso油,$[ESO]>D油油one油o$on"
 油油油油油油油油a油Ssin"油_SSIN足I,"cutdt油cut余
油油油油油油}
 油油油油油油,
油油油油油油_tp油油=油u油
 油油油油油油so油油油>sb{
油油油油油油油油sy"eso油,$[ESO]>D油油a油tpe"
 油油油油油油油油a油Ssin"油_SSIN足I,"hssopd余
油油油油油油}
 油油油油油油,
油油油油}
 油油油油
油油)
 油油余
}

PE:enl>u(余
 O:Kre足rn)
REFLEX
Written by author of POE
"How POE would be written if I had Moose back then"
Stresses composability, reusability
Includes plenty of additional roles
USING MOOSE
{
油油pcaeAp
 油油akg油p余
油油ueMoe
 油油s油os余
油油etns'elx:ae余
 油油xed油Rfe:Bs'
油油ueRfe:Itra余
 油油s油elx:nevl
油油ueRfe:Tat:ace油wths余
 油油s油elx:ri:Wthd'ace'
油
油油wthstce油>(
 油油ace油ikr=油
油油油油ia油=油Rfe:Itra'
 油油油油s油油>'elx:nevl,
油油油油stp=油油nevl=油,at_eet=油油,
 油油油油eu油>{itra油>1油uorpa油>1}
油油)
 油油余
油
油油sbo_ikrtc油
 油油u油ntce_ik{
油油油油sy'ika油,saa(oatm)油..余
 油油油油a油tc油t'油clrlclie,'.'
油油}
 油油
}
油
ei油p足nw)>u_l(余
 xtAp>e(足rnal)
COMPLEX? TRY THIS...
ueRfe:Itra余
 s油elx:nevl
油
m油t=Rfe:Itra足nw
 y$油油elx:nevl>e(
油油itra油油=油,
 油油nevl油油>1
油油at_eet=油,
 油油uorpa油>1
油油o_ik油油=油u油油a油tmrtce'}
 油油ntc油油油>sb{sy'ie油ikd油,
)余
油
$足rnal)
 t>u_l(余
ANYEVENT
AnyEvent is very thin and very fast
Was written to support as many loops as possible
... that conform to the author's rules of compatibility
Does not use a loop handler, simply runs
Does use conditional variables
Has AE for faster performance
ueAyvn余
 s油nEet
m油cut=0
 y$on油油余
m油c油油=Ayvn足cnvr
 y$v油油油nEet>oda余
m油t油油=Ayvn足tmr
 y$油油油油nEet>ie(
油油atr油油>2
 油油fe油油=油,
油油itra油>06
 油油nevl=油.,
油油c油油油油>sb{
 油油b油油油=油u油
油油油油sy'h油iei油o:'油nEet>o余
 油油油油a油Tetm油snw油,Ayvn足nw
油油油油+$on油=1油n油c足sn余
 油油油油+cut=油0ad$v>ed
油油}
 油油,
)余

$v>ev
 c足rc余
m油w油w=Ayvn足i(
 y$余$油油nEet>o
油油f油油>SDN
 油油h油=油*TI,
油油pl油>''
 油油ol=油r,
油油c油油>sb{
 油油b油=油u油
油油油油cop(m油ipt=油余
 油油油油hm油油y$nu油油)
油油油油sy"ed油ipt余
 油油油油a油ra:$nu"
油油油油udf$余
 油油油油ne油w
油油}
 油油,
)余
USAGES OF ASYNCHRONOUS CODE
     GUI
     Services (HTTP/SMTP/etc.)
     Performance
     Off-loading tasks
THANK YOU

More Related Content

What's hot (12)

The Wolf
The Wolf The Wolf
The Wolf
Jon David Leslie
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
Wes Oldenbeuving
Adventure time
Adventure timeAdventure time
Adventure time
Teodor_Cristian
CS50 Lecture2
CS50 Lecture2CS50 Lecture2
CS50 Lecture2
Day2
Day2Day2
Day2
Avilay Parekh
Mahabhara katha
Mahabhara kathaMahabhara katha
Mahabhara katha
mianagpur
CS50 Lecture1
CS50 Lecture1CS50 Lecture1
CS50 Lecture1
Entschuldigung, das wei ich leider nicht.
Entschuldigung,  das wei ich leider nicht.Entschuldigung,  das wei ich leider nicht.
Entschuldigung, das wei ich leider nicht.
Andreas Kwiatkowski
Yahoo! JAPANKotlin
Yahoo! JAPANKotlinYahoo! JAPANKotlin
Yahoo! JAPANKotlin
Shoichi Matsuda
01 linux basics
01 linux basics01 linux basics
01 linux basics
Robson Levi
Making sense of big data
Making sense of big dataMaking sense of big data
Making sense of big data
Charlie Hull
Big Data LDN 2016: Making Sense of Big Data with Open Source Search
Big Data LDN 2016: Making Sense of Big Data with Open Source SearchBig Data LDN 2016: Making Sense of Big Data with Open Source Search
Big Data LDN 2016: Making Sense of Big Data with Open Source Search
Matt Stubbs
An introduction to Ruby
An introduction to RubyAn introduction to Ruby
An introduction to Ruby
Wes Oldenbeuving
CS50 Lecture2
CS50 Lecture2CS50 Lecture2
CS50 Lecture2
Mahabhara katha
Mahabhara kathaMahabhara katha
Mahabhara katha
mianagpur
CS50 Lecture1
CS50 Lecture1CS50 Lecture1
CS50 Lecture1
Entschuldigung, das wei ich leider nicht.
Entschuldigung,  das wei ich leider nicht.Entschuldigung,  das wei ich leider nicht.
Entschuldigung, das wei ich leider nicht.
Andreas Kwiatkowski
01 linux basics
01 linux basics01 linux basics
01 linux basics
Robson Levi
Making sense of big data
Making sense of big dataMaking sense of big data
Making sense of big data
Charlie Hull
Big Data LDN 2016: Making Sense of Big Data with Open Source Search
Big Data LDN 2016: Making Sense of Big Data with Open Source SearchBig Data LDN 2016: Making Sense of Big Data with Open Source Search
Big Data LDN 2016: Making Sense of Big Data with Open Source Search
Matt Stubbs

Similar to Asynchronous programming FTW! (6)

Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
Wojciech Sznapka
Presenting Seq for Node.js
Presenting Seq for Node.jsPresenting Seq for Node.js
Presenting Seq for Node.js
Douglas Muth
Javascript: The Important Bits
Javascript: The Important BitsJavascript: The Important Bits
Javascript: The Important Bits
Zumba Fitness - Technology Team
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
Johannes Hoppe
TicketBEKA? Ticket booking
TicketBEKA? Ticket bookingTicketBEKA? Ticket booking
TicketBEKA? Ticket booking
Likhith Pujari
Front End Dependency Management at CascadiaJS
Front End Dependency Management at CascadiaJSFront End Dependency Management at CascadiaJS
Front End Dependency Management at CascadiaJS
Joe Sepi
Automated tests - facts and myths
Automated tests - facts and mythsAutomated tests - facts and myths
Automated tests - facts and myths
Wojciech Sznapka
Presenting Seq for Node.js
Presenting Seq for Node.jsPresenting Seq for Node.js
Presenting Seq for Node.js
Douglas Muth
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
2013-02-21 - .NET UG Rhein-Neckar: JavaScript Best Practices
Johannes Hoppe
TicketBEKA? Ticket booking
TicketBEKA? Ticket bookingTicketBEKA? Ticket booking
TicketBEKA? Ticket booking
Likhith Pujari
Front End Dependency Management at CascadiaJS
Front End Dependency Management at CascadiaJSFront End Dependency Management at CascadiaJS
Front End Dependency Management at CascadiaJS
Joe Sepi

More from xSawyer (14)

do_this and die();
do_this and die();do_this and die();
do_this and die();
xSawyer
XS Fun
XS FunXS Fun
XS Fun
xSawyer
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
xSawyer
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012
xSawyer
Our local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variablesOur local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variables
xSawyer
Your first website in under a minute with Dancer
Your first website in under a minute with DancerYour first website in under a minute with Dancer
Your first website in under a minute with Dancer
xSawyer
Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)
xSawyer
PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)
xSawyer
Perl Dancer for Python programmers
Perl Dancer for Python programmersPerl Dancer for Python programmers
Perl Dancer for Python programmers
xSawyer
When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)
xSawyer
Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)
xSawyer
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systems
xSawyer
Moose (Perl 5)
Moose (Perl 5)Moose (Perl 5)
Moose (Perl 5)
xSawyer
Red Flags in Programming
Red Flags in ProgrammingRed Flags in Programming
Red Flags in Programming
xSawyer
do_this and die();
do_this and die();do_this and die();
do_this and die();
xSawyer
XS Fun
XS FunXS Fun
XS Fun
xSawyer
Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)Asynchronous Programming FTW! 2 (with AnyEvent)
Asynchronous Programming FTW! 2 (with AnyEvent)
xSawyer
Moose - YAPC::NA 2012
Moose - YAPC::NA 2012Moose - YAPC::NA 2012
Moose - YAPC::NA 2012
xSawyer
Our local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variablesOur local state, my, my - Understanding Perl variables
Our local state, my, my - Understanding Perl variables
xSawyer
Your first website in under a minute with Dancer
Your first website in under a minute with DancerYour first website in under a minute with Dancer
Your first website in under a minute with Dancer
xSawyer
Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)Moose talk at FOSDEM 2011 (Perl devroom)
Moose talk at FOSDEM 2011 (Perl devroom)
xSawyer
PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)PerlDancer for Perlers (FOSDEM 2011)
PerlDancer for Perlers (FOSDEM 2011)
xSawyer
Perl Dancer for Python programmers
Perl Dancer for Python programmersPerl Dancer for Python programmers
Perl Dancer for Python programmers
xSawyer
When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)When Perl Met Android (YAPC::EU 2010)
When Perl Met Android (YAPC::EU 2010)
xSawyer
Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)Perl Dancer on Android (first attempt)
Perl Dancer on Android (first attempt)
xSawyer
Source Code Management systems
Source Code Management systemsSource Code Management systems
Source Code Management systems
xSawyer
Moose (Perl 5)
Moose (Perl 5)Moose (Perl 5)
Moose (Perl 5)
xSawyer
Red Flags in Programming
Red Flags in ProgrammingRed Flags in Programming
Red Flags in Programming
xSawyer

Recently uploaded (20)

Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Buwaneka De Silva
Top 10 Mobile Hacking Tools 2025 Edition
Top 10 Mobile Hacking Tools  2025 EditionTop 10 Mobile Hacking Tools  2025 Edition
Top 10 Mobile Hacking Tools 2025 Edition
anishachhikara2122
TNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptxTNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptx
MohamedHasan816582
Human Centered Design By Gnanasambandham
Human Centered Design By GnanasambandhamHuman Centered Design By Gnanasambandham
Human Centered Design By Gnanasambandham
Gnanasambandham Anbazhagan CSP, CSM, CSPO
Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...
Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...
Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...
Tobias Schneck
Q1 FY26 TUG Leader Quarterly Call - APAC / EMEA
Q1 FY26 TUG Leader Quarterly Call - APAC / EMEAQ1 FY26 TUG Leader Quarterly Call - APAC / EMEA
Q1 FY26 TUG Leader Quarterly Call - APAC / EMEA
lward7
APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
TrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic Relationship
TrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic RelationshipTrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic Relationship
TrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic Relationship
TrustArc
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
DanBrown980551
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD TechnicianRicardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno
Threat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community DayThreat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community Day
Teri Radichel
Artificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examplesArtificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examples
anandsimple
Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...
Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...
Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...
3G4G
AC2-Agile-Agile concepts in an enterprise environment
AC2-Agile-Agile concepts in an enterprise environmentAC2-Agile-Agile concepts in an enterprise environment
AC2-Agile-Agile concepts in an enterprise environment
Dennis Van Aelst
Introduction to Mobile App Development.
Introduction to  Mobile App Development.Introduction to  Mobile App Development.
Introduction to Mobile App Development.
AkashDwivedi43
AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)
MetaSenseMarketing
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc鱈a Lavilla
Presentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdfPresentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdf
Mukesh Kala
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdfHandout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Scott Sosna
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to EndIntroduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
christopherneo4
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Atlassian Community - Human-Centered AI in Product Management Unleashing Inno...
Buwaneka De Silva
Top 10 Mobile Hacking Tools 2025 Edition
Top 10 Mobile Hacking Tools  2025 EditionTop 10 Mobile Hacking Tools  2025 Edition
Top 10 Mobile Hacking Tools 2025 Edition
anishachhikara2122
TNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptxTNBC Research Presentation and medical virology .pptx
TNBC Research Presentation and medical virology .pptx
MohamedHasan816582
Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...
Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...
Evaluating Global Load Balancing Options for Kubernetes in Practice (Kubermat...
Tobias Schneck
Q1 FY26 TUG Leader Quarterly Call - APAC / EMEA
Q1 FY26 TUG Leader Quarterly Call - APAC / EMEAQ1 FY26 TUG Leader Quarterly Call - APAC / EMEA
Q1 FY26 TUG Leader Quarterly Call - APAC / EMEA
lward7
APAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdfAPAC Solutions Challenge Info Session.pdf
APAC Solutions Challenge Info Session.pdf
GDG on Campus Monash
TrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic Relationship
TrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic RelationshipTrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic Relationship
TrustArc Webinar - Data Privacy and Cyber Security: A Symbiotic Relationship
TrustArc
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
CitrineOS: Bridging the Past and Future of EV Charging with OCPP 1.6 & 2.x Su...
DanBrown980551
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD TechnicianRicardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno - A Structural CAD Technician
Ricardo Jebb Bruno
Threat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community DayThreat Modeling a Batch Job System - AWS Security Community Day
Threat Modeling a Batch Job System - AWS Security Community Day
Teri Radichel
Artificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examplesArtificial Neural Networks, basics, its variations and examples
Artificial Neural Networks, basics, its variations and examples
anandsimple
Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...
Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...
Misc: The Internet Story - How Data Travels, Transit Works, and the Role of C...
3G4G
AC2-Agile-Agile concepts in an enterprise environment
AC2-Agile-Agile concepts in an enterprise environmentAC2-Agile-Agile concepts in an enterprise environment
AC2-Agile-Agile concepts in an enterprise environment
Dennis Van Aelst
Introduction to Mobile App Development.
Introduction to  Mobile App Development.Introduction to  Mobile App Development.
Introduction to Mobile App Development.
AkashDwivedi43
AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)AI in SEO Marketing Presentation (BY MetaSense Marketing)
AI in SEO Marketing Presentation (BY MetaSense Marketing)
MetaSenseMarketing
Commit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with KubescapeCommit Conf 2025 Bitnami Charts with Kubescape
Commit Conf 2025 Bitnami Charts with Kubescape
Alfredo Garc鱈a Lavilla
Presentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdfPresentation Session 4 -Agent Builder.pdf
Presentation Session 4 -Agent Builder.pdf
Mukesh Kala
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdfHandout - Demonolithing Think Again (Devoxx GR 2025).pdf
Handout - Demonolithing Think Again (Devoxx GR 2025).pdf
Scott Sosna
Introduction to PHP from Beginning to End
Introduction to PHP from Beginning to EndIntroduction to PHP from Beginning to End
Introduction to PHP from Beginning to End
christopherneo4

Asynchronous programming FTW!

  • 1. ASYNCHRONOUS PROGRAMMING FTW! (SAWYER X)
  • 2. DOES THIS SOUND FAMILIAR? "Hi" "Hi, dad" "Got a minute?" "Yes" "I'm looking for a movie Where do I start?" "Go to the cinema website" "What's the address?" "www.whatchamacallit.whatever" "Just a sec..."
  • 4. "Well?" "Ah! It loaded! What now?" "Click on new movies" "OK..." ........ "Well?" "Loading" *sounds of clicks*
  • 5. "OK, now what?" "Find a movie you want" "Then what?" "Click on it, you'll have instructions" * eternity passes by * "WELL?!?" "Just a sec... it's loading..." /me shoots myself
  • 6. ILLUSTRATED (USING WWW::MECHANIZE) $eh>e(cnm_r) mc足gt$ieaul余 i油油mc足sces){ f($eh>ucs油油 油油$eh>lc(NwMve'余 油油mc足cik'e油ois) 油油i油油mc足sces){ 油油f($eh>ucs油油 油油油油m油mve油油mc足fn_nus.. 油油油油y@ois=$eh>idipt(.) 油油} 油油 }
  • 7. LET'S TRY THIS AGAIN... "Hi" "Hi, dad" "Got a minute?" "Yes" "I'm looking for a movie What should I do?" "Go to this website, click on new movies Then pick a movie, and click on it" "Thank you" "You're welcome"
  • 9. CALLBACKS Reference to a code Passed as an argument Can be called by some other code sbtysmtig{ u油r_oehn油 油油m油ipt油油hf余 油油y$nu油=sit 油油m油c油油油油hf余 油油y$b油油=sit 油油m油rsl油油oeoeain$nu) 油油y$eut=sm_prto(ipt余 油油i油油rsl足{sau'油q'K油油 油油f($eut>'tts}e油O'){ 油油油油$b>油rsl足{cnet}) 油油油油c足($eut>'otn'油余 油油} 油油 } tysmtig油sm油admipt,sb{ r_oehn("oerno油nu"油u油 油油m油cnet=sit 油油y$otn油油hf余 油油sy"ucsflrqetsy油cnet" 油油a油Scesu油eus油as$otn!余 }) 油余
  • 10. ILLUSTRATED, ASYNC (USING WWW::MECHANIZE) $eh>e($ieaul油u油 mc足gt油cnm_r,sb{ 油油$eh>lc('e油ois,sb{ 油油mc足cik油NwMve'油u油 油油油油$eh>idipt(..油u油油y@ois=@油油 油油油油mc足fn_nus油.,sb{m油mve油油_}) 油油}) 油油油余 }) 油余
  • 11. WHY IS THIS USEFUL? Allow others to decide if something is good or not
  • 12. m油jn油油uo>e( y$uo=Jn足nw 油油hss油>[w11112222] 油油ot油=油q<...油...>, 油油cek油>{ 油油hcs=油 油油油油Fig=油 油油油油Pn油>{ 油油油油油油o_ucs油>sb{ 油油油油油油nsces=油u油 油油油油油油油油m油油jn,$ot油dt油油油_ 油油油油油油油油y($uo油hs,$aa)=@余 油油油油油油油油m油油i,$os油ag)=$uo>nlz_igrsl( 油油油油油油油油y($p油ls,$v油油油jn足aayepn_eut 油油油油油油油油油油$aa>'ter} 油油油油油油油油油油dt足{sdr', 油油油油油油油油) 油油油油油油油油余 油油油油油油油油$ef>e_ot油hs,$v油余 油油油油油油油油sl足sths($ot油ag) 油油油油油油} 油油油油油油, 油油油油油油o_al=油u油 油油油油油油nfi油>sb{ 油油油油油油油油m油油jn,$ot)=@余 油油油油油油油油y($uo油hs油油油_ 油油油油油油油油$ef>eeehs(hs) 油油油油油油油油sl足dlt_ot$ot余 油油油油油油} 油油油油油油, 油油油油} 油油油油 油油} 油油 )余
  • 13. WHY IS THIS USEFUL? Allow others to decide if something is good or not Allow easy stepping
  • 14. Algorithm::Diff::Callback ueAgrtm:if:alakq<ifary油ifhse> s油loih:Df:Clbc油wdf_rasdf_ahs余 df_ras ifary( 油油odfml_ebr, 油油@l_aiymmes 油油nwfml_ebr, 油油@e_aiymmes 油油sb{pit'ap油oha油bu油,sit} 油油u油油rn油Hpyt油eraot'油hf油, 油油sb{pit'or油oha油bu油,sit} 油油u油油rn油Sryt油eraot'油hf油, )余 df_ahs ifhse( 油油oddtis 油油%l_eal, 油油nwdtis 油油%e_eal, 油油sb{sy'ot'油油hf油, 油油u油油a油Ls油,油sit} 油油sb{sy'and'油hf油, 油油u油油a油Gie油,sit} 油油sb{ 油油u油 油油油油m油油ky油bfr,$fe油油油_ 油油油油y($e,$eoe油atr)=@余 油油油油sy"kycagdfo油bfr油o$fe" 油油油油a油$e油hne油rm$eoet油atr余 油油} 油油, )余
  • 15. WHY IS THIS USEFUL? Allow others to decide if something is good or not Allow easy stepping Allow control by other process (a type of IOC) Allow asynchronous code
  • 16. THE EVENT LOOP Create loop Register events Run them Let the user keep registering new events
  • 17. m油eet油油..余 y%vns=(.) wie(){ hl油1油 油油frahm油eet(ky油eet油油 油油oec油y$vn油油es%vns){ 油油油油$vn足(余 油油油油eet>) 油油} 油油 }
  • 18. m油eet余%vns=(.) y%vns油eet油油..余 wie(){ hl油1油 油油frahm油eet(ky油eet油油 油油oec油y$vn油油es%vns){ 油油油油$vn足(余 油油油油eet>) 油油} 油油 } wie(){ hl油1油 油油frahm油eet(ky油eet油油 油油oec油y$vn油油es%vns){ 油油油油i油油eet{eet{tm'油=tm油油 油油油油f($vns$vn}'ie}<油ie){ 油油油油油油$vns$vn}'oe}>) 油油油油油油eet{eet{cd'足(余 油油油油} 油油油油 油油} 油油 } sbadeet{ u油d_vn油 油油m油油tm,$oe)=@余 油油y($ie油cd油油油_ 油油$vns$d{tm'油油tm余 油油eet{i}'ie}=$ie 油油$vns$d{cd'油油cd余 油油eet{i}'oe}=$oe 油油$d+ 油油i+余 }
  • 19. EVENT TYPES Timers (one-time, recurring, sleep replacement) I/O (input output, including networking)
  • 20. FUCK TALK LET'S GO PROGRAMMING
  • 21. IO::ASYNC Loop interface: IO::Async::Loop You can connect to hosts using it You can add listeners to it (handles, sockets, etc.) Explicitly call "run" when ready
  • 22. ueI:Ayc:tem s油O:sn:Sra余 ueI:Ayc:op s油O:sn:Lo余 油 m油lo油油O:sn:Lo足nw y$op=I:Ayc:op>e余 $op>onc( lo足cnet 油油hs油油油=油sm.te.ot, 油油ot油油油>"oeohrhs" 油油srie油=油24, 油油evc油油>135 油油sctp油=油sra' 油油okye油>'tem, 油油 油油o_tem=油u油油.油, 油油nsra油>sb{..} 油油 油油o_eov_ro油>sb{ 油油nrsleerr=油u油 油油油油de"antrsle足$[1" 油油油油i油Cno油eov油油_足] 油油} 油油, 油油o_onc_ro油>sb{ 油油ncneterr=油u油 油油油油de"antcnet足$[]fie油_足] 油油油油i油Cno油onc油油_0油ald$[1" 油油} 油油, )余 $op>u余 lo足rn
  • 23. o_tem=油u油 nsra油>sb{ 油油m油油sra油油油_ 油油y($tem)=@余 油油$tem>ofgr( 油油sra足cniue 油油油油o_ed=油u油 油油油油nra油>sb{ 油油油油油油m油油sl,$ufe,$o油油油_ 油油油油油油y($ef油bfrf油ef)=@余 油油油油油油wie油{bfrf油~s^.)/){ 油油油油油油hl($$ufe}=油/(*n/油油 油油油油油油油油sy"eevdaln油1余 油油油油油油油油a油Rcie油油ie$" 油油油油油油} 油油油油油油 油油油油油油rtr油余 油油油油油油eun0 油油油油} 油油油油 油油) 油油余 油油$tem>rt(A油nta油iehr'余 油油sra足wie'niiilln油ee) 油油$op>d(sra) 油油lo足ad$tem余 }
  • 24. ANOTHER EXAMPLE $pr油MO:sn油Me:Ayc:TP足油 油el足I:Ayc足Nt:sn:HT油E' 油油I:Ayc>d(m油ht油油e:Ayc:TP>e油余 油油O:sn足ad油y$tp=Nt:sn:HT足nw) 油油syfrI:Ayc>wi_l(mp{$tp>e(_油油) 油油a油o油O:sn足aatal油a油油ht足gt$)}油 '>ls足fUL.x 油油ito足Rstt Oh hai parallel HTTP GET!
  • 25. POE Loop interface: POE::Kernel Runs "sessions" (POE::Session) Each session is a context of events Each session has an ID and heap Call events in a current or different session Explicitly call POE::Kernel->run when ready
  • 26. POE uePE油#At足nldsPE:enladPE:eso. s油O余油油uoicue油O:Kre油n油O:Ssin #..dfn油alak油us(etsie油. 油.油eieclbcssb油nx油ld).. fr(.1){ o油1.0油 油油PE:eso足cet( 油油O:Ssin>rae 油油油油iln_tts=油 油油油油niesae油>{ 油油油油油油_tr油油=油&ade_tr, 油油油油油油sat油油>hnlrsat 油油油油油油iceet=油&ade_nrmn, 油油油油油油nrmn油>hnlriceet 油油油油油油_tp油油=油&ade_tp 油油油油油油so油油油>hnlrso, 油油油油} 油油油油 油油) 油油余 } PE:enl>u(余 O:Kre足rn)
  • 27. sbhnlrsat{ u油ade_tr油 油m油油kre,$ep油ssin)=@[KRE,HA,SSIN] 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余 油sy"eso油,$eso足I,"hssatd余 油a油Ssin"油ssin>D油油a油tre" 油$ep>'on'油油余 油ha足{cut}=0 油$enl>il(iceet) 油kre足yed'nrmn'余 } sbhnlriceet{ u油ade_nrmn油 油m油油kre,$ep油ssin)=@[KRE,HA,SSIN] 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余 油sy"eso油,$eso足I,"cutdt油,+$ep>'on'余 油a油Ssin"油ssin>D油油one油o"油+ha足{cut} 油$enl>il(iceet)i油ha足{cut}<1余 油kre足yed'nrmn'油f$ep>'on'油油0 } sbhnlrso油 u油ade_tp{ 油sy"eso油,$[ESO]>D油油a油tpe" 油a油Ssin"油_SSIN足I,"hssopd余 }
  • 28. sbhnlrsat{ u油ade_tr油 油m油油kre,$ep油ssin)=@[KRE,HA,SSIN] 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余 油sy"eso油,$eso足I,"hssatd余 油a油Ssin"油ssin>D油油a油tre" 油$ep>'on'油油余 油ha足{cut}=0 油$enl>il(iceet) 油kre足yed'nrmn'余 } sbhnlriceet{ u油ade_nrmn油 油m油油kre,$ep油ssin)=@[KRE,HA,SSIN] 油y($enl油ha,$eso油油油_油ENL油EP油ESO油余 油sy"eso油,$eso足I,"cutdt油,+$ep>'on'余 油a油Ssin"油ssin>D油油one油o"油+ha足{cut} 油$enl>il(iceet)i油ha足{cut}<1余 油kre足yed'nrmn'油f$ep>'on'油油0 } sbhnlrso油 u油ade_tp{ 油sy"eso油,$[ESO]>D油油a油tpe.n余 油a油Ssin"油_SSIN足I,"hssopd" } fr(.1){ o油1.0油 油油PE:eso足cet( 油油O:Ssin>rae 油油油油iln_tts=油 油油油油niesae油>{ 油油油油油油_tr油油=油&ade_tr, 油油油油油油sat油油>hnlrsat 油油油油油油iceet=油&ade_nrmn, 油油油油油油nrmn油>hnlriceet 油油油油油油_tp油油=油&ade_tp 油油油油油油so油油油>hnlrso, 油油油油} 油油油油 油油) 油油余 } PE:enl>u(余 O:Kre足rn)
  • 29. MORE CONDENSED uePE s油O余 fr(.1){ o油1.0油 油油m油cut=0 油油y$on油油余 油油PE:eso足cet( 油油O:Ssin>rae 油油油油iln_tts=油 油油油油niesae油>{ 油油油油油油_tr油油=油u油 油油油油油油sat油油>sb{ 油油油油油油油油sy"eso油,$[ESO]>D油油a油tre" 油油油油油油油油a油Ssin"油_SSIN足I,"hssatd余 油油油油油油油油PE:enl>il(iceet) 油油油油油油油油O:Kre足yed'nrmn'余 油油油油油油} 油油油油油油, 油油油油油油iceet=油u油 油油油油油油nrmn油>sb{ 油油油油油油油油PE:enl>il(iceet)i油+cut<1余 油油油油油油油油O:Kre足yed'nrmn'油f+$on油油0 油油油油油油油油sy"eso油,$[ESO]>D油油one油o$on" 油油油油油油油油a油Ssin"油_SSIN足I,"cutdt油cut余 油油油油油油} 油油油油油油, 油油油油油油_tp油油=油u油 油油油油油油so油油油>sb{ 油油油油油油油油sy"eso油,$[ESO]>D油油a油tpe" 油油油油油油油油a油Ssin"油_SSIN足I,"hssopd余 油油油油油油} 油油油油油油, 油油油油} 油油油油 油油) 油油余 } PE:enl>u(余 O:Kre足rn)
  • 30. REFLEX Written by author of POE "How POE would be written if I had Moose back then" Stresses composability, reusability Includes plenty of additional roles
  • 31. USING MOOSE { 油油pcaeAp 油油akg油p余 油油ueMoe 油油s油os余 油油etns'elx:ae余 油油xed油Rfe:Bs' 油油ueRfe:Itra余 油油s油elx:nevl 油油ueRfe:Tat:ace油wths余 油油s油elx:ri:Wthd'ace' 油 油油wthstce油>( 油油ace油ikr=油 油油油油ia油=油Rfe:Itra' 油油油油s油油>'elx:nevl, 油油油油stp=油油nevl=油,at_eet=油油, 油油油油eu油>{itra油>1油uorpa油>1} 油油) 油油余 油 油油sbo_ikrtc油 油油u油ntce_ik{ 油油油油sy'ika油,saa(oatm)油..余 油油油油a油tc油t'油clrlclie,'.' 油油} 油油 } 油 ei油p足nw)>u_l(余 xtAp>e(足rnal)
  • 32. COMPLEX? TRY THIS... ueRfe:Itra余 s油elx:nevl 油 m油t=Rfe:Itra足nw y$油油elx:nevl>e( 油油itra油油=油, 油油nevl油油>1 油油at_eet=油, 油油uorpa油>1 油油o_ik油油=油u油油a油tmrtce'} 油油ntc油油油>sb{sy'ie油ikd油, )余 油 $足rnal) t>u_l(余
  • 33. ANYEVENT AnyEvent is very thin and very fast Was written to support as many loops as possible ... that conform to the author's rules of compatibility Does not use a loop handler, simply runs Does use conditional variables Has AE for faster performance
  • 34. ueAyvn余 s油nEet m油cut=0 y$on油油余 m油c油油=Ayvn足cnvr y$v油油油nEet>oda余 m油t油油=Ayvn足tmr y$油油油油nEet>ie( 油油atr油油>2 油油fe油油=油, 油油itra油>06 油油nevl=油., 油油c油油油油>sb{ 油油b油油油=油u油 油油油油sy'h油iei油o:'油nEet>o余 油油油油a油Tetm油snw油,Ayvn足nw 油油油油+$on油=1油n油c足sn余 油油油油+cut=油0ad$v>ed 油油} 油油, )余 $v>ev c足rc余
  • 35. m油w油w=Ayvn足i( y$余$油油nEet>o 油油f油油>SDN 油油h油=油*TI, 油油pl油>'' 油油ol=油r, 油油c油油>sb{ 油油b油=油u油 油油油油cop(m油ipt=油余 油油油油hm油油y$nu油油) 油油油油sy"ed油ipt余 油油油油a油ra:$nu" 油油油油udf$余 油油油油ne油w 油油} 油油, )余
  • 36. USAGES OF ASYNCHRONOUS CODE GUI Services (HTTP/SMTP/etc.) Performance Off-loading tasks