cml.tex

来自「这是我们参加06年全国开源软件的竞赛作品」· TEX 代码 · 共 336 行 · 第 1/2 页

TEX
336
字号
\maybeclearpage\section{The {\cf CML} structure}\begin{synopsis}\item {\kw{signature}} \textcf{CML}\label{sig-CML}\item {\STRUCTURE} \textcf{CML: CML}\label{str-CML}\end{synopsis}\begin{interface}\Nopagebreak\item {\index{thread_id@thread\_\linebreak[0]id!CML@\textcf{CML}}}{\kw{type}} \textcf{thread\_\linebreak[0]id}\Nopagebreak\item {\index{chan@chan!CML@\textcf{CML}}}{\kw{type}} \(\alpha\)~\textcf{chan}\Nopagebreak\item {\index{event@event!CML@\textcf{CML}}}{\kw{type}} \(\alpha\)~\textcf{event}\Nopagebreak\item {\index{version@version!CML@\textcf{CML}}}{\kw{val}} {\cf version: \(\{\mbox{\cf{}system}:\mbox{\cf{}string},\,\mbox{\cf{}version\_id}:\mbox{\cf{}int}\;\mbox{\cf{}list},\,\mbox{\cf{}date}:\mbox{\cf{}string}\}\)}\item {\index{banner@banner!CML@\textcf{CML}}}{\kw{val}} {\cf banner: \(\mbox{\cf{}string}\)}\Nopagebreak\item {\index{spawnc@spawnc!CML@\textcf{CML}}}{\kw{val}} {\cf spawnc: \((\alpha\rightarrow \mbox{\cf{}unit})\rightarrow \alpha\rightarrow \mbox{\cf{}thread\_id}\)}\item {\index{spawn@spawn!CML@\textcf{CML}}}{\kw{val}} {\cf spawn: \((\mbox{\cf{}unit}\rightarrow \mbox{\cf{}unit})\rightarrow \mbox{\cf{}thread\_id}\)}\Nopagebreak\item {\index{yield@yield!CML@\textcf{CML}}}{\kw{val}} {\cf yield: \(\mbox{\cf{}unit}\rightarrow \mbox{\cf{}unit}\)}\Nopagebreak\item {\index{exit@exit!CML@\textcf{CML}}}{\kw{val}} {\cf exit: \(\mbox{\cf{}unit}\rightarrow \alpha\)}\Nopagebreak\item {\index{getTid@getTid!CML@\textcf{CML}}}{\kw{val}} {\cf getTid: \(\mbox{\cf{}unit}\rightarrow \mbox{\cf{}thread\_id}\)}\Nopagebreak\item {\index{sameTid@sameTid!CML@\textcf{CML}}}{\kw{val}} {\cf sameTid: \((\mbox{\cf{}thread\_id}\mtoksep{}\verb,*,\mtoksep{}\mbox{\cf{}thread\_id})\rightarrow \mbox{\cf{}bool}\)}\Nopagebreak\item {\index{compareTid@compareTid!CML@\textcf{CML}}}{\kw{val}} {\cf compareTid: \((\mbox{\cf{}thread\_id}\mtoksep{}\verb,*,\mtoksep{}\mbox{\cf{}thread\_id})\rightarrow \mbox{\cf{}order}\)}\Nopagebreak\item {\index{hashTid@hashTid!CML@\textcf{CML}}}{\kw{val}} {\cf hashTid: \(\mbox{\cf{}thread\_id}\rightarrow \mbox{\cf{}word}\)}\Nopagebreak\item {\index{tidToString@tidToString!CML@\textcf{CML}}}{\kw{val}} {\cf tidToString: \(\mbox{\cf{}thread\_id}\rightarrow \mbox{\cf{}string}\)}\Nopagebreak\item {\index{joinEvt@joinEvt!CML@\textcf{CML}}}{\kw{val}} {\cf joinEvt: \(\mbox{\cf{}thread\_id}\rightarrow \mbox{\cf{}unit}\;\mbox{\cf{}event}\)}\Nopagebreak\item {\index{channel@channel!CML@\textcf{CML}}}{\kw{val}} {\cf channel: \(\mbox{\cf{}unit}\rightarrow \alpha\mtoksep{}\mbox{\cf{}chan}\)}\Nopagebreak\item {\index{sameChannel@sameChannel!CML@\textcf{CML}}}{\kw{val}} {\cf sameChannel: \((\alpha\mtoksep{}\mbox{\cf{}chan}\mtoksep{}\verb,*,\mtoksep{}\alpha\mtoksep{}\mbox{\cf{}chan})\rightarrow \mbox{\cf{}bool}\)}\Nopagebreak\item {\index{send@send!CML@\textcf{CML}}}{\kw{val}} {\cf send: \((\alpha\mtoksep{}\mbox{\cf{}chan}\mtoksep{}\verb,*,\mtoksep{}\alpha)\rightarrow \mbox{\cf{}unit}\)}\Nopagebreak\item {\index{recv@recv!CML@\textcf{CML}}}{\kw{val}} {\cf recv: \(\alpha\mtoksep{}\mbox{\cf{}chan}\rightarrow \alpha\)}\Nopagebreak\item {\index{sendEvt@sendEvt!CML@\textcf{CML}}}{\kw{val}} {\cf sendEvt: \((\alpha\mtoksep{}\mbox{\cf{}chan}\mtoksep{}\verb,*,\mtoksep{}\alpha)\rightarrow \mbox{\cf{}unit}\;\mbox{\cf{}event}\)}\item {\index{recvEvt@recvEvt!CML@\textcf{CML}}}{\kw{val}} {\cf recvEvt: \(\alpha\mtoksep{}\mbox{\cf{}chan}\rightarrow \alpha\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{sendPoll@sendPoll!CML@\textcf{CML}}}{\kw{val}} {\cf sendPoll: \((\alpha\mtoksep{}\mbox{\cf{}chan}\mtoksep{}\verb,*,\mtoksep{}\alpha)\rightarrow \mbox{\cf{}bool}\)}\Nopagebreak\item {\index{recvPoll@recvPoll!CML@\textcf{CML}}}{\kw{val}} {\cf recvPoll: \(\alpha\mtoksep{}\mbox{\cf{}chan}\rightarrow \alpha\mtoksep{}\mbox{\cf{}option}\)}\Nopagebreak\item {\index{wrap@wrap!CML@\textcf{CML}}}{\kw{val}} {\cf wrap: \((\alpha\mtoksep{}\mbox{\cf{}event}\mtoksep{}\verb,*,(\alpha\rightarrow \beta))\rightarrow \beta\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{wrapHandler@wrapHandler!CML@\textcf{CML}}}{\kw{val}} {\cf wrapHandler: \((\alpha\mtoksep{}\mbox{\cf{}event}\mtoksep{}\verb,*,(\mbox{\cf{}exn}\rightarrow \alpha\mtoksep{}\mbox{\cf{}event}))\rightarrow \alpha\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{guard@guard!CML@\textcf{CML}}}{\kw{val}} {\cf guard: \((\mbox{\cf{}unit}\rightarrow \alpha\mtoksep{}\mbox{\cf{}event})\rightarrow \alpha\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{withNack@withNack!CML@\textcf{CML}}}{\kw{val}} {\cf withNack: \((\mbox{\cf{}unit}\;\mbox{\cf{}event}\rightarrow \alpha\mtoksep{}\mbox{\cf{}event})\rightarrow \alpha\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{choose@choose!CML@\textcf{CML}}}{\kw{val}} {\cf choose: \(\alpha\mtoksep{}\mbox{\cf{}event}\;\mbox{\cf{}list}\rightarrow \alpha\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{sync@sync!CML@\textcf{CML}}}{\kw{val}} {\cf sync: \(\alpha\mtoksep{}\mbox{\cf{}event}\rightarrow \alpha\)}\Nopagebreak\item {\index{select@select!CML@\textcf{CML}}}{\kw{val}} {\cf select: \(\alpha\mtoksep{}\mbox{\cf{}event}\;\mbox{\cf{}list}\rightarrow \alpha\)}\Nopagebreak\item {\index{never@never!CML@\textcf{CML}}}{\kw{val}} {\cf never: \(\alpha\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{alwaysEvt@alwaysEvt!CML@\textcf{CML}}}{\kw{val}} {\cf alwaysEvt: \(\alpha\rightarrow \alpha\mtoksep{}\mbox{\cf{}event}\)}\Nopagebreak\item {\index{timeOutEvt@timeOutEvt!CML@\textcf{CML}}}{\kw{val}} {\cf timeOutEvt: \(\mbox{\cf{}Time}.\mbox{\cf{}time}\rightarrow \mbox{\cf{}unit}\;\mbox{\cf{}event}\)}\Nopagebreak\item {\index{atTimeEvt@atTimeEvt!CML@\textcf{CML}}}{\kw{val}} {\cf atTimeEvt: \(\mbox{\cf{}Time}.\mbox{\cf{}time}\rightarrow \mbox{\cf{}unit}\;\mbox{\cf{}event}\)}\end{interface}\begin{descr}\item {\index{thread_id@thread\_\linebreak[0]id!CML@\textcf{CML}}}{\kw{type}} \textcf{thread\_\linebreak[0]id}\label{ty-CML.thread_id}\begin{speccomment}\item 	  Thread IDs are the unique IDs associated with CML threads. 	  These IDs are in an unspecified total order that can be used to 	  break cyclic depedencies (see {\cf \small compare\-Tid}).     \end{speccomment}\item {\index{chan@chan!CML@\textcf{CML}}}{\kw{type}} \(\alpha\)~\textcf{chan}\label{ty-CML.chan}\begin{speccomment}\item           This is the type constructor for synchronous channels.     \end{speccomment}\item {\index{event@event!CML@\textcf{CML}}}{\kw{type}} \(\alpha\)~\textcf{event}\label{ty-CML.event}\begin{speccomment}\item 	  Event values are abstract representations of synchronous operations 	  (so called \emph{first-class sychronous operations}).     \end{speccomment}\item {\index{version@version!CML@\textcf{CML}}}{\kw{val}} {\cf version: \(\{\mbox{\cf{}system}:\mbox{\cf{}string},\,\mbox{\cf{}version\_id}:\mbox{\cf{}int}\;\mbox{\cf{}list},\,\mbox{\cf{}date}:\mbox{\cf{}string}\}\)}\label{val-CML.version}\item {\index{banner@banner!CML@\textcf{CML}}}{\kw{val}} {\cf banner: \(\mbox{\cf{}string}\)}\label{val-CML.banner}\begin{speccomment}\item 	These specify the version of CML in the same format as SML/NJ.     \end{speccomment}\item {\index{spawnc@spawnc!CML@\textcf{CML}}}{\kw{val}} {\cf spawnc: \((\alpha\rightarrow \mbox{\cf{}unit})\rightarrow \alpha\rightarrow \mbox{\cf{}thread\_id}\)}\label{val-CML.spawnc}\item {\index{spawn@spawn!CML@\textcf{CML}}}{\kw{val}} {\cf spawn: \((\mbox{\cf{}unit}\rightarrow \mbox{\cf{}unit})\rightarrow \mbox{\cf{}thread\_id}\)}\label{val-CML.spawn}\begin{speccomment}\item {\cf \small spawnc \mbox{\cf \small \textit{f}} \mbox{\cf \small \textit{x}} 	\newline}{\cf \small           spawn \mbox{\cf \small \textit{f}}         } creates a new thread of control to evaluate the body of \mbox{\cf \small \textit{f}}. 	A new unique ID for the thread is created and returned.     \end{speccomment}\item {\index{yield@yield!CML@\textcf{CML}}}{\kw{val}} {\cf yield: \(\mbox{\cf{}unit}\rightarrow \mbox{\cf{}unit}\)}\label{val-CML.yield}\begin{speccomment}\item 	This function can be used to implement an explicit context switch. 	Since CML is preemptively scheduled, it should never be necessary for 	user programs to call this function. 	It is mainly used for performance measurements.     \end{speccomment}\item {\index{exit@exit!CML@\textcf{CML}}}{\kw{val}} {\cf exit: \(\mbox{\cf{}unit}\rightarrow \alpha\)}\label{val-CML.exit}\begin{speccomment}\item {\cf \small exit () 	} causes the calling thread to terminate.     \end{speccomment}\item {\index{getTid@getTid!CML@\textcf{CML}}}{\kw{val}} {\cf getTid: \(\mbox{\cf{}unit}\rightarrow \mbox{\cf{}thread\_id}\)}\label{val-CML.getTid}\begin{speccomment}\item {\cf \small get\-Tid ()           } returns the thread ID of the calling thread.     \end{speccomment}\item {\index{sameTid@sameTid!CML@\textcf{CML}}}{\kw{val}} {\cf sameTid: \((\mbox{\cf{}thread\_id}\mtoksep{}\verb,*,\mtoksep{}\mbox{\cf{}thread\_id})\rightarrow \mbox{\cf{}bool}\)}\label{val-CML.sameTid}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?