Commits

Alessio Caiazza committed ad663d6

all contents added

Comments (0)

Files changed (7)

 }
 
 \subsection{Supervisors}
+{
+\usebackgroundtemplate{\includegraphics{images/supervisor.jpg}}
+\frame[plain]{}
+}
 \frame{\frametitle{Supervisor - Class definition}
 \begin{block}{}     
 	\rubysource[firstnumber=1,firstline=4,lastline=16]{sources/unfair_battle}
 	\rubyout{sources/unfair_battle}
 \end{block}
 }
+\subsection{Linking}
+{
+\usebackgroundtemplate{\includegraphics{images/links.jpg}}
+\frame[plain]{}
+}
+\frame{\frametitle{Links - Class definition}
+\begin{block}{}     
+	\rubysource[firstline=18,lastline=29]{sources/links}
+\end{block}
+}
 
+\frame{\frametitle{Links - Usage}
+\begin{block}{}     
+	\rubysource[firstline=31,lastline=37]{sources/links}
+	\pause
+	\rubyout[lastline=4]{sources/links}
+\end{block}
+}
 
-% \subsection{Orientato agli oggetti}
-% \vskip 11pt
-% \frame[t]{\frametitle{In ruby tutto č un oggetto}
-% \begin{block}{Tutto č un oggetto, vediamo alcune chiamate di metodi}
-% 	\only<1>{\RubyXMP[0.43\textwidth]{}{sources/object}}
-% 	\only<2>{\RubyXMP[0.43\textwidth]{}{sources/object2}}
-% \end{block}
-% }
+\subsection{Groups}
+{
+\usebackgroundtemplate{\includegraphics{images/groups.jpg}}
+\frame[plain]{}
+}
+\frame{\frametitle{Groups - Class definition}
+\begin{block}{LogisticChief}
+	\rubysource[firstline=39,lastline=51]{sources/links}
+\end{block}
+}
+\frame{\frametitle{Groups - Class definition}
+\begin{block}{LogisticChief cont...}
+	\rubysource[firstnumber=14,firstline=52,lastline=60]{sources/links}
+\end{block}
+}
+
+\frame{\frametitle{Groups - Class definition}
+\begin{block}{} %lord marshal
+	\rubysource[firstline=62,lastline=70]{sources/links}
+\end{block}
+}
+
+\frame{\frametitle{Groups - Class definition}
+\begin{block}{MainGroup}
+	\rubysource[firstline=72,lastline=87]{sources/links}
+\end{block}
+}
+
+\frame{\frametitle{Groups - Class definition}
+\begin{block}{MainGroup cont...}
+	\rubysource[firstnumber=17,firstline=89]{sources/links}     
+	\pause
+	\rubyout[firstline=5]{sources/links}
+\end{block}
+}
+
+\section{Conclusions}
+\subsection{Groups}
+{
+\usebackgroundtemplate{\includegraphics{images/conclusions_bg.jpg}}
+\frame[plain,t]{
+\vspace{0.5cm}
+\sidebyside{\phantom{spacespacespacespacespacespace}}{
+\textcolor{white}{Interaction over composition.}\\
+\textcolor{white}{Messages over shared variables.}\\
+\textcolor{white}{Balance load on different actors.}\\
+\textcolor{white}{Let it crash and reload a safe state.}
+}
+}
+}
+

images/conclusions_bg.jpg

Added
New image

images/groups.jpg

Added
New image

images/links.jpg

Added
New image

images/supervisor.jpg

Added
New image
 \begin{frame}
 	\frametitle{Erlang}
 	\begin{block}{Erlang was designed to help you writing system that are ...}
-	\begin{itemize}[<+->]
+	\begin{itemize}%[<+->]
 		\item distributed
 		\item scalable
 		\item reliable
 require 'celluloid'
-#Celluloid.logger.level = Logger::FATAL
+Celluloid.logger = nil
 
 class NecroMonger
   include Celluloid
 class LogisticChief
   include Celluloid
   
+  def count_assets
+    Celluloid::Actor.all
+    .select { |a| a.class.name.start_with? "Necro" }
+    .inject({}) do |sum,itm|
+      idx = itm.class.name.to_sym
+      current = sum[idx] || 0
+      sum[idx] = current + 1
+      sum
+    end
+  end
   def prepare_reinforcements
     if (count_assets[:NecroMongerFighter] || 0) < 3
-      lord_marshal = Celluloid::Actor[:lord_marshal]
+      lord_marshal = Actor[:lord_marshal]
       3.times { lord_marshal.link NecroMongerFighter.new }
     else
       p "We have enough troops Lord Marshal!"
     end
   end
-  
-  def count_assets
-    Celluloid::Actor.all.inject({}) do |sum,itm|
-      begin
-        idx = itm.class.name.to_sym
-        current = sum[idx] || 0
-        sum[idx] = current + 1
-        sum
-      rescue Celluloid::DeadActorError
-      end
-    end
-  end
 end
 
 class LordMarshal
   include Celluloid
   trap_exit :necromonger_died
-  attr_reader :logistic
-  
-  def initialize
-    @logistic = LogisticChief.new_link
-  end
 
   def necromonger_died(actor, reason)
     p "Damn Riddick! #{actor.inspect} has died because of a #{reason.class}"
-    @logistic.prepare_reinforcements!
+    Actor[:logistic].prepare_reinforcements!
+  end
+end
+
+class MainGroup < Celluloid::Group
+  supervise LordMarshal, :as => :lord_marshal
+  supervise LogisticChief, :as => :logistic
+  def initialize
+    super
+    after(3) do
+      zhylaw = Actor[:lord_marshal]
+      vehicle = NecroMongerFighter.new
+
+      zhylaw.link vehicle.pilot
+      puts Actor[:logistic].count_assets
+      vehicle.attack_riddick_amanjaro!
+      sleep 1
+      signal :finished, Actor[:logistic].count_assets
+    end
   end
   
+  def wait_backgroud_execution
+    wait :finished
+  end
 end
 
-zhylaw = (LordMarshal.supervise_as :lord_marshal).actor
-vehicle = NecroMongerFighter.new
-
-zhylaw.link vehicle.pilot
-puts zhylaw.logistic.count_assets
-vehicle.attack_riddick_amanjaro!
-sleep 1
-puts zhylaw.logistic.count_assets
-sleep 10
+main = MainGroup.run!
+puts main.actor.wait_backgroud_execution