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.

inspectanelementormergeatableataparticularposition,locatethe subtablefromatable,ndthesizeofthetable,<strong>and</strong>iterate(repeataset ofstatementsonceforeachelementofthetable). positionofanelementwithparticularcontents,<strong>and</strong>iterateinorder. Orderedtablesadditionallysupporttheseoperations:insert,remove,or InBoundedBuffer,thesingleactionofthePutserviceconsistsofinsertingthedesignatedlineintotheendofthetableQueue.Theinsert<br />

1.Introductionto<strong>Hermes</strong>29<br />

ifyouwish,bywriting: isordered.However,youmayinsertelementsatanypositioninthetable statementinsertsanelementintotheendofatablebydefaultifthetable<br />

toinsertsomethingatposition3,theremustbeanelementatposition2, anelementpreviouslyatposition3,itmovestoposition4,<strong>and</strong>similarly orelseyouwillgetaRangeErrorexception. allelementsathigherpositionshavetheirpositionsincremented.Ifyoutry youspecifyposition3,thenewelementappearsatposition3.Iftherewas insertElementintoTableat(Position); Inthiscase,youmustsupplyaninteger-valuedposition.Forexample,if<br />

thepositionsofalltheotherelementsmoveupbyone,sotheprevious wewrotetheexpressioncopyof. inGetCM.Line.Whenyouremovetherstelementfromanorderedtable, discardPutCM.Line|inthedenitionofPutLineInterface,parameter intothetable,ratherthancopyingit.Thismeansthatafterthestatement Lineisconstant|wemustmoveacopyofPutCM.Line.Thatexplainswhy isexecuted,thesourceoper<strong>and</strong>isdiscarded.Sincewe'renotallowedto TheGetserviceclauseremovestherstentryfromthetable<strong>and</strong>placesit Onemoretechnicalpointaboutinsert:thestatementmovesitsoper<strong>and</strong><br />

meanssimplythrowingitaway.Callmessages<strong>and</strong>portsaretreatedspecially:Whenacallmessage,oranyvaluewhichcancontaincallmessages<br />

TheQuitservicecallterminatestheloop,<strong>and</strong>henceterminatesthe nalized|thatis,theirvaluesarediscarded.InBoundedBuffer,thatwould bethequeue,thebooleanvariableRunning,thethreeserviceports,<strong>and</strong> secondelementnowbecomesrst. theinitializationport.Formost<strong>Hermes</strong>datatypes,discardingthevalue process. executingitslaststatement.Allvariableswhichremaininitializedare-<br />

discarded,thecallmessagesarereturned.EachcallmessagetypehasadefaultDiscardedexception,e.g.GetLineInterface.Discarded.Whenan<br />

Disconnectedexception.Anyprocesswhichbecomesisolatedbecauseall itsconnectionstotheoutsideworldarebrokenisequivalenttoaterminated inputportisdiscarded,connectionstothatportarebroken;attemptsto (e.g.aninputportwhichmayhaveseveralcallmessagesonitsqueue)is Let'slookmorecloselyatprocesstermination.Aprocessterminatesafter<br />

process<strong>and</strong>canbesafelygarbage-collectedbytheimplementation. sendmessagesoverthoseconnectionswillfail<strong>and</strong>thecallerwillreceivea

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

Saved successfully!

Ooh no, something went wrong!