\doxysection{tk::Actor$<$ Msg\+Type, Queue\+Size $>$ クラステンプレート} \label{classtk_1_1_actor}\index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} メッセージ駆動型タスク (アクター) の基底クラス {\ttfamily \+\#include $<$actor.\+hpp$>$} \doxysubsubsection*{公開メンバ関数} \begin{DoxyCompactItemize} \item \textbf{ Actor} ()=default \item virtual \textbf{ $\sim$\+Actor} () \item bool \textbf{ start} (uint32\+\_\+t prio=\textbf{ PRIO\+\_\+\+NORMAL}) \begin{DoxyCompactList}\small\item\em \doxyref{Actor}{p.}{classtk_1_1_actor} をタスクとして生成し、\+Event\+Hub へ自動登録します \end{DoxyCompactList}\item bool \textbf{ post} (const Msg\+Type \&msg) \begin{DoxyCompactList}\small\item\em この \doxyref{Actor}{p.}{classtk_1_1_actor} のメッセージキューへ直接メッセージを送信します (コピー渡し) \end{DoxyCompactList}\item bool \textbf{ post} (Msg\+Type \&\&msg) \begin{DoxyCompactList}\small\item\em この \doxyref{Actor}{p.}{classtk_1_1_actor} のメッセージキューへ直接メッセージを送信します (ムーブ渡し) \end{DoxyCompactList}\item {\footnotesize template$<$typename U = Msg\+Type$>$ }\\std::\+enable\+\_\+if$<$ std::\+is\+\_\+same$<$ U, \textbf{ Message} $>$::\+value, bool $>$::\+type \textbf{ post} (uint32\+\_\+t id, uintptr\+\_\+t arg=0) \begin{DoxyCompactList}\small\item\em \doxyref{tk::\+\+Message}{p.}{structtk_1_1_message} 型の場合のコンビニエンス送信関数 \end{DoxyCompactList}\item \textbf{ Task\+Handle} \textbf{ handle} () const \end{DoxyCompactItemize} \doxysubsubsection*{限定公開メンバ関数} \begin{DoxyCompactItemize} \item virtual void \textbf{ on\+\_\+start} () \begin{DoxyCompactList}\small\item\em タスク起動時、イベントループ突入直前に1度だけ呼ばれる初期化関数 \end{DoxyCompactList}\item virtual void \textbf{ on\+\_\+message} (const Msg\+Type \&msg)=0 \begin{DoxyCompactList}\small\item\em メッセージ受信時に呼ばれるハンドラ関数 \end{DoxyCompactList}\end{DoxyCompactItemize} \doxysubsection{詳解} \subsubsection*{template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$\newline class tk::\+\+Actor$<$ Msg\+Type, Queue\+Size $>$} メッセージ駆動型タスク (アクター) の基底クラス 固定長リングバッファ付きのメッセージキューを持ち、メッセージ到着時に自動起床して {\ttfamily \doxyref{on\+\_\+message()}{p.}{classtk_1_1_actor_a1147554d6ddb64d822285ca5a03506a4}} を実行します。メッセージが無い時は CPU を消費せずブロック待機します。 \begin{DoxyTemplParams}{テンプレート引数} {\em Msg\+Type} & 受信するメッセージの型 (デフォルト: \doxyref{tk::\+\+Message}{p.}{structtk_1_1_message}) \\ \hline {\em Queue\+Size} & メッセージキューの最大保持件数 (デフォルト: 8)\\ \hline \end{DoxyTemplParams} \begin{DoxyCode}{0} \DoxyCodeLine{\textcolor{keyword}{struct\ }SensorMsg\ \{\ \textcolor{keywordtype}{float}\ temp;\ \};} \DoxyCodeLine{} \DoxyCodeLine{\textcolor{keyword}{class\ }SensorActor\ :\ \textcolor{keyword}{public}\ tk::Actor\ \{} \DoxyCodeLine{\textcolor{keyword}{protected}:} \DoxyCodeLine{\ \ \ \ \textcolor{keywordtype}{void}\ on\_start()\textcolor{keyword}{\ override\ }\{} \DoxyCodeLine{\ \ \ \ \ \ \ \ \textcolor{comment}{//\ デバイスの初期化}} \DoxyCodeLine{\ \ \ \ \}} \DoxyCodeLine{\ \ \ \ \textcolor{keywordtype}{void}\ on\_message(\textcolor{keyword}{const}\ SensorMsg\&\ msg)\textcolor{keyword}{\ override\ }\{} \DoxyCodeLine{\ \ \ \ \ \ \ \ printf(\textcolor{stringliteral}{"{}Temp:\ \%.1f\(\backslash\)n"{}},\ msg.temp);} \DoxyCodeLine{\ \ \ \ \}} \DoxyCodeLine{\};} \end{DoxyCode} \label{classtk_1_1_actor_doc-constructors} \doxysubsection{構築子と解体子} \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!Actor@{Actor}} \index{Actor@{Actor}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{Actor()} {\footnotesize\ttfamily \label{classtk_1_1_actor_a776aef8cdcfb4416ef976697eb518ed5} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+\+Actor (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [default]}} \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!````~Actor@{$\sim$Actor}} \index{````~Actor@{$\sim$Actor}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{$\sim$Actor()} {\footnotesize\ttfamily \label{classtk_1_1_actor_abfc63a514a3ae7cdbdf9ceee81c3b0fc} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ virtual \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+$\sim$\textbf{ Actor} (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [virtual]}} \label{classtk_1_1_actor_doc-func-members} \doxysubsection{関数詳解} \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!handle@{handle}} \index{handle@{handle}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{handle()} {\footnotesize\ttfamily \label{classtk_1_1_actor_a60a2752360fa7185ec7776f2a6ef766a} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ \textbf{ Task\+Handle} \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+handle (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}} この \doxyref{Actor}{p.}{classtk_1_1_actor} のタスクハンドルを取得 \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!on\_message@{on\_message}} \index{on\_message@{on\_message}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{on\_message()} {\footnotesize\ttfamily \label{classtk_1_1_actor_a1147554d6ddb64d822285ca5a03506a4} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ virtual void \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+on\+\_\+message (\begin{DoxyParamCaption}\item[{const Msg\+Type \&}]{msg}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [protected]}, {\ttfamily [pure virtual]}} メッセージ受信時に呼ばれるハンドラ関数 キューから取り出されたメッセージの実体への参照が渡されます。 派生クラスで必ず実装します。 \begin{DoxyParams}{引数} {\em msg} & 受信したメッセージ \\ \hline \end{DoxyParams} \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!on\_start@{on\_start}} \index{on\_start@{on\_start}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{on\_start()} {\footnotesize\ttfamily \label{classtk_1_1_actor_afb31ec0d50d1ac97e6a4ce148a96f78d} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ virtual void \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+on\+\_\+start (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}, {\ttfamily [protected]}, {\ttfamily [virtual]}} タスク起動時、イベントループ突入直前に1度だけ呼ばれる初期化関数 タスクコンテキスト内で実行されるため、{\ttfamily \doxyref{tk::\+sleep\+\_\+ms()}{p.}{namespacetk_aae83f84121085578a7568437a8dc2447}} を使った初期化ウェイトも安全に行えます。 必要に応じて派生クラスでオーバーライドします。 \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!post@{post}} \index{post@{post}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{post()\hspace{0.1cm}{\footnotesize\ttfamily [1/3]}} {\footnotesize\ttfamily \label{classtk_1_1_actor_a224e6be4dca0d1500f2121e97bd0f92d} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ bool \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+post (\begin{DoxyParamCaption}\item[{const Msg\+Type \&}]{msg}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}} この \doxyref{Actor}{p.}{classtk_1_1_actor} のメッセージキューへ直接メッセージを送信します (コピー渡し) スレッドセーフ・割り込みセーフ・マルチコアセーフです。 \begin{DoxyParams}{引数} {\em msg} & 送信するメッセージ \\ \hline \end{DoxyParams} \begin{DoxyReturn}{戻り値} true 送信成功, false キューが満杯 \end{DoxyReturn} \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!post@{post}} \index{post@{post}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{post()\hspace{0.1cm}{\footnotesize\ttfamily [2/3]}} {\footnotesize\ttfamily \label{classtk_1_1_actor_a863f28d824aaa78c75789166b1c2a010} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ bool \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+post (\begin{DoxyParamCaption}\item[{Msg\+Type \&\&}]{msg}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}} この \doxyref{Actor}{p.}{classtk_1_1_actor} のメッセージキューへ直接メッセージを送信します (ムーブ渡し) \begin{DoxyParams}{引数} {\em msg} & 送信するメッセージ (ムーブ) \\ \hline \end{DoxyParams} \begin{DoxyReturn}{戻り値} true 送信成功, false キューが満杯 \end{DoxyReturn} \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!post@{post}} \index{post@{post}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{post()\hspace{0.1cm}{\footnotesize\ttfamily [3/3]}} {\footnotesize\ttfamily \label{classtk_1_1_actor_a5c4f4f2f1b8011a37773617e34218c2d} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ template$<$typename U = Msg\+Type$>$ \\ std::\+enable\+\_\+if$<$ std::\+is\+\_\+same$<$ U, \textbf{ Message} $>$::\+value, bool $>$::\+type \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+post (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{id}{, }\item[{uintptr\+\_\+t}]{arg}{ = {\ttfamily 0}}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}} \doxyref{tk::\+\+Message}{p.}{structtk_1_1_message} 型の場合のコンビニエンス送信関数 \begin{DoxyParams}{引数} {\em id} & メッセージ\+ID \\ \hline {\em arg} & 引数 (省略時: 0) \\ \hline \end{DoxyParams} \begin{DoxyReturn}{戻り値} true 送信成功, false キューが満杯 \end{DoxyReturn} \index{tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}!start@{start}} \index{start@{start}!tk::Actor$<$ MsgType, QueueSize $>$@{tk::Actor$<$ MsgType, QueueSize $>$}} \doxysubsubsection{start()} {\footnotesize\ttfamily \label{classtk_1_1_actor_ac98ec3132f2ded910a6899b030c06f3f} template$<$typename Msg\+Type = Message, size\+\_\+t Queue\+Size = 8$>$ \\ bool \textbf{ tk::\+\+Actor}$<$ Msg\+Type, Queue\+Size $>$::\+start (\begin{DoxyParamCaption}\item[{uint32\+\_\+t}]{prio}{ = {\ttfamily \textbf{ PRIO\+\_\+\+NORMAL}}}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}} \doxyref{Actor}{p.}{classtk_1_1_actor} をタスクとして生成し、\+Event\+Hub へ自動登録します {\ttfamily \doxyref{tk::\+start()}{p.}{namespacetk_a675f1829b87e2a43239b6f80a526d0ed}} を呼び出す前に登録する必要があります。 \begin{DoxyParams}{引数} {\em prio} & タスク優先度 (省略時: \doxyref{tk::\+\+PRIO\+\_\+\+NORMAL}{p.}{namespacetk_a3d47fbd63b95ed3b46bed70c2fa1e50ea0e6779023b97999c2cef66ba1d4d1fca}) \\ \hline \end{DoxyParams} \begin{DoxyReturn}{戻り値} true 登録成功, false 登録失敗 (タスク枠上限など) \end{DoxyReturn} このクラス詳解は次のファイルから抽出されました:\begin{DoxyCompactItemize} \item C:\+/\+\+Users/\+yoneda/\+\+Documents/\+\+Pico\+\_\+\+Projects/\+tinykernel/\+tinykernel/\+include/\+tinykernel/\textbf{ actor.\+hpp}\end{DoxyCompactItemize}