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.

604.1.ExpressionBlocks anexpressionblockifyouneedtowriteastatement. blockwasn'treallynecessary.Theoriginalversionwasjustasconvenient. builtwithintheexpressionblock.Inthisparticularcase,theexpression However,insomecontexts,suchasafterwhereinaselector,youmustuse statement.Theoper<strong>and</strong>ofinsertistherecordCurrentWindowwhichis Inthisversionoftheprogram,theblockconsistsofasingleinsert<br />

4.2Send Anothercommonidiomistosendsomedatatoanotherprocess<strong>and</strong>not waitforareply.Youc<strong>and</strong>othisbydeninganinterfaceinwhichthedata youwishtosendisinitializedonentry<strong>and</strong>uninitializedonexit.However, thereisstilltheproblemthatthereceivingprocessmaychoosetowait<br />

statementsendvariabletoportcausesthevaluecurrentlyinvariableto indenitelybeforereceivingyourdata.Itmayevenrunforever<strong>and</strong>never process,<strong>Hermes</strong>providesanasynchronouscommunicationmechanism.The beremoved<strong>and</strong>senttothequeueattheinputportconnectedtoport. deadlocked,itisIwhoisblocked<strong>and</strong>notS. <strong>and</strong>returnstoS.ThenIcallstheeventualreceiverR.IfRisdelayedor receiveyourdata.<br />

Becauseofthesendoperation,inputportscanbedenedtoholdany intermediateprocessI.ScallsI,whichimmediatelyreceivesthedata, Ratherthanrequiringtheprogrammertoexplicitlycodeanintermediate Apossible<strong>Hermes</strong>solutionisthis:thesendingprocess,Screatesan<br />

datatype,notjustcallmessages. Herearetwopracticalusesofsend: Communicatingwithuntrustedprocesses:SupposeIwishtoload<strong>and</strong> Ieithermustspawnaprocesstoinitialize<strong>and</strong>calltheuntrusted willneverreturnmycallmessage,<strong>and</strong>Iwillblockforever.Tobesafe, thisifIdonottrusttheprocessIamloading.Perhapstheprocess statement. process,orImustdelivertheinitializationparametersusingasend aswedidinearlierexamples.However,thereissomerisktodoing someports.Icouldpassthisinformationwithacallstatement,just executeaprocess<strong>and</strong>passitsomeinitializationinformation|possibly<br />

Forwardingcalls:SupposeIamwritingaprocesswhosejobitisto tuallyservicethecall.Ifmyprocessreceivesthecallmessage<strong>and</strong>then receivecalls<strong>and</strong>routethemtoanappropriateprocesswhichwillac-<br />

callstheeventualdestination,itmustwaituntilthecallisserviced. originalcaller,<strong>and</strong>nottomyprocess. However,ifinsteadmyprocesstransfersthecallmessageusingsend, myprocessisfreetorouteothercalls.Whentheeventualdestination issuesareturnstatement,thecallmessagewillbereturnedtothe

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

Saved successfully!

Ooh no, something went wrong!