# HG changeset patch # User ichikitakahiro # Date 1620287255 -32400 # Node ID d0df325948740275326cf8f6c70c4f514acfa99d # Parent 4d1009ff72c57f2112ed76a7cd80fcc336857c8e add images diff -r 4d1009ff72c5 -r d0df32594874 Paper/paper.pdf Binary file Paper/paper.pdf has changed diff -r 4d1009ff72c5 -r d0df32594874 Paper/paper.tex --- a/Paper/paper.tex Thu May 06 16:14:15 2021 +0900 +++ b/Paper/paper.tex Thu May 06 16:47:35 2021 +0900 @@ -291,17 +291,126 @@ WordCountの例題は大きく分けて, 指定した名前のファイルをFIle構造体としてOpenするFileOpenスレッド, ファイル構造体を受け取り文字列(word)を表示し文字数(bytes)と行数(lines)をCountUpするWordCountスレッドの二つのCodeGearで記述することができる. 図\ref{fig:WCGearbox}で示したWordCountの遷移図はFileをオープンしたCGとWordCountのCGを巡回することにより, - + \ref{codes: StartHelloCG} + \ref{fig:WCStates} + \ref{fig:WCDGMwChristie} + \begin{figure}[tb] \begin{center} - \includegraphics[width=80mm]{images/wordCountGearBox.pdf} + \includegraphics[width=80mm]{images/wordCountStates.pdf} \end{center} - \caption{WordCount with Gearbox} - \label{fig:WCGearbox} + \caption{WordCount with CbC} + \label{fig:WCStates} \end{figure} +\begin{lstlisting}[frame=lrbt,label=codes: UnixFI,caption={UnixFileImpl.cbc}] +#include +#impl UnixFileImp as "UnixFileImpl.h" + + +File* createUnixFileImpl(struct Context* context) { + File *file = new File(); + file->FileImpl = (union Data*)new FileImpl(); + return file; +} + +readBlock(UnixFileImpl* file) { + Block *block = new Block(); + int len = read(fd, BUFSIZE, block->data); + block->eof &= ~BLOCK_FLAG_EOF; + if (len <=0 ) { + block->eof |= BLOCK_FLAG_EOF; + close(file->fd); + } + return block ; +} + +__code unixOpen(UnixFileImpl* file,Key *key, __code next(Block *block,...)); + file->fd = open(key->path,unix_mode(key->modde)); + if (fd < 0) { + goto error("can't open"); + } + goto next(readBlock(file), ...); +} + +__code uniAck(UnixFileImpl* file,Ack *ack, __code next(Block *block,...)); + if (!ack->isOk) { + close(file->fd); + goto next(...); + } + goto next(readBlock(file), ...); // file is automaticaly put into local dataGearManger/input +} +\end{lstlisting} + + +\begin{lstlisting}[frame=lrbt,label=codes: WCImple,caption={WcImpl.cbc}] +#include "../../../context.h" +#include +#impl "Wc.h" as "WcImpl.h" +#interface "WcResult.h" + +Wc* createWcImpl(struct Context* context) { + Wc *wc = new Wc(); + wc->wc = (union Data*)new WcImpl(); + wc->bytes = 0; + wc->words = 0; + wc->lines = 0; + return wc; +} + +__code take(Impl* wc, Block *block,__code next(Ack *ack, ...),__code finish(StdData *result,...) { + if (isEof(block->eof )) { + result.buffer = new Buffer(1); + result.buffer->data = new Byte(BUSIZE); + result.size = 1; + result.buffer->size = + snprintf(result.buffer[0]->data, "%d %d %d\n",wc->bytes,wc->words,wc->lines); + goto finish(resut); + } + for(size_t i = 0 ; isize; i++) { + if (block->data[i] == '\n') wc->lines++; + if (block->data[i] == ' ') { + wc->words++; + while(block->data[i] == ' ') { + if(i>=block->size) + goto next(ack,take); + i++; + wc->bytes++; + } + } + wc->bytes++; + } + goto next(ack,take); +} +\end{lstlisting} + + +\begin{figure}[tb] + \begin{center} + \includegraphics[width=80mm]{images/wordCountDGM.pdf} + \end{center} + \caption{WordCountDGM with Christie} + \label{fig:WCDGMwChristie} +\end{figure} + + +\begin{figure}[tb] + \begin{center} + \includegraphics[width=80mm]{images/fileImplementation.pdf} + \end{center} + \caption{file Implementation} + \label{fig:fileImpletation} +\end{figure} + +\begin{figure}[tb] + \begin{center} + \includegraphics[width=80mm]{images/filePersistency.pdf} + \end{center} + \caption{file Persistency} + \label{fig:filePersist} +\end{figure}