Skip to content

Instantly share code, notes, and snippets.

@adizere
Last active September 26, 2016 13:22
Show Gist options
  • Save adizere/bf7423045e05aa53c4f3 to your computer and use it in GitHub Desktop.
Save adizere/bf7423045e05aa53c4f3 to your computer and use it in GitHub Desktop.
Latex sample for algorithm implementation, as used in CS-451 Distributed Algorithms
\begin{alltt}
\normalfont
\textbf{Implements}:
UniformReliableBroadcast, \textbf{instance} \textit{urb}.
\textbf{Uses}:
IdealPerfectPointToPointLinks, \textbf{instance} \textit{idealpl}.
\textbf{upon event} \textit{\(<\)urb, Init\(>\)} \textbf{do}
\textit{delivered} := \(\emptyset\);
\textbf{upon event} \textit{\(<\)urb, Broadcast \(|\) \textit{m}\(>\)} \textbf{do}
\textbf{trigger} \textit{\(<\)idealpl, Send \(|\) self, (DATA, self, m)\(>\)};
\textbf{upon event} \textit{\(<\)idealpl, Deliver \(|\) p, (DATA, s, m)\(>\)} \textbf{do}
\textbf{if} \textit{m} \(\not\in\) \textit{delivered} \textbf{then}
\textit{delivered} := \textit{delivered} \(\cup\) (\textit{m});
\textbf{forall} \textit{q} \(\in \Pi\)
\textbf{trigger} \textit{\(<\)idealpl, Send \(|\) q, (DATA, s, m)\(>\)};
\textbf{trigger} \textit{\(<\)urb, Deliver \(|\) s, m\(>\)};
\end{alltt}
@adizere
Copy link
Author

adizere commented Oct 28, 2015

Yields the following snippet:

screen shot 2015-10-28 at 12 58 01

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment