28.01.2015 Views

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

Hermes: A Tutorial and Reference Manual - Researcher - IBM

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Ifallalternativesaredisabled,thentheotherwiseclauseisexecuted.If oneormorealternativesareenabled,oneofthemischosen,<strong>and</strong>control transferstothatalternative.However,analternativewithaneventguard canonlybechosenifthatinputporthasatleastonewaitingcallmessage. ports,theselectstatementblocksuntilamessagearrivesatoneofthese Ifalltheenabledalternativeshaveeventguardsreferringtoemptyinput 1.Introductionto<strong>Hermes</strong>27<br />

buer.JustleaveoutthequeuesizetestfromthePutservice. whichcontainsdenitionsfortypesusedinternallybyBoundedBuffer(in nativeisenabledprovidedthenumberoflinesinthequeueislessthan inthequeue.Theotherwiseclause,althoughsyntacticallym<strong>and</strong>atory, canneverbereached.Itiseasytomodifythisprogramintoanunbounded ports.<br />

thiscase,thetypeLinesusedtoimplementthequeue),(2)BBExternal, Capacity,<strong>and</strong>theGetalternativeisenabledprovidedthereareanylines Theboundedbuerprocessusesfourinterfaces:(1)BBLocal(notshown), Inthisexample,theQuitalternativeisalwaysenabled;thePutalter-<br />

buer. languagefeatureswe'vealreadydescribed.Trytowriteityourself<strong>and</strong>then checkwiththedenitionhere: ules,becausetheywillbereusedinapplicationsotherthanthebounded whichdenesthePutLine<strong>and</strong>GetLine,<strong>and</strong>(4)Quit,whichdenesthe interfacefortheQuitoperation.St<strong>and</strong>ard<strong>and</strong>Quitareinseparatemod-<br />

whichdenestheinitializationinterfacefortheboundedbuer,(3)St<strong>and</strong>ard, Theinterfacedenition,BBExternal,isstraightforward,<strong>and</strong>usesonly BBInterface:callmessage( BBExternal:using(Quit,St<strong>and</strong>ard)definitions<br />

BBIn:inportofBBInterfacefinit(Capacity)g; BBOut:outportofBBIn; Capacity:integer,--maximumnumberofmessagesallowed<br />

enddefinitions Put:PutLineOut,--portforwriters<br />

TheQuitdenitionisevensimpler: Get:GetLineOut,--portforreaders<br />

Quit:using()definitions constant(Capacity) exitffullg; Quit:QuitOut)--portforshutdown<br />

object-orientedlanguageslikeSmalltalkInbothcases,wehavetheability enddefinitions Howdoes<strong>Hermes</strong>dierfromdataabstractionlanguageslikeAdaor QuitIn:inportofQuitInterfacefg; QuitInterface:callmessage()exitfg; QuitOut:outportofQuitIn;

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!