classtk_1_1_mutex.tex 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. \doxysection{tk::Mutex Class Reference}
  2. \hypertarget{classtk_1_1_mutex}{}\label{classtk_1_1_mutex}\index{tk::Mutex@{tk::Mutex}}
  3. 所有権・優先度順ウェイクアップ・\+RAII 対応のミューテックス (排他ロック)
  4. {\ttfamily \+\#include $<$sync.\+hpp$>$}
  5. \doxysubsubsection*{Public Member Functions}
  6. \begin{DoxyCompactItemize}
  7. \item
  8. \doxymbox{\hyperlink{classtk_1_1_mutex_a8b17431db60f4ab48a3859b2ca722eb1}{Mutex}} ()=default
  9. \item
  10. void \doxymbox{\hyperlink{classtk_1_1_mutex_a7f5645bba55df2db263f92a954802c27}{lock}} ()
  11. \begin{DoxyCompactList}\small\item\em ミューテックスをロックします (空くまでブロック待機) \end{DoxyCompactList}\item
  12. bool \doxymbox{\hyperlink{classtk_1_1_mutex_a666dd03fb22c5cb855e3145f76a58b9c}{try\+\_\+lock}} ()
  13. \begin{DoxyCompactList}\small\item\em ミューテックスのロックを試みます (ノンブロッキング) \end{DoxyCompactList}\item
  14. void \doxymbox{\hyperlink{classtk_1_1_mutex_ae8d5dfd5655b5aa54d63db6e0cf2f707}{unlock}} ()
  15. \begin{DoxyCompactList}\small\item\em ミューテックスのロックを解除します \end{DoxyCompactList}\item
  16. bool \doxymbox{\hyperlink{classtk_1_1_mutex_acf574e35540879481f1f6e5452a504ab}{is\+\_\+locked}} () const
  17. \end{DoxyCompactItemize}
  18. \doxysubsection{Detailed Description}
  19. 所有権・優先度順ウェイクアップ・\+RAII 対応のミューテックス (排他ロック)
  20. 共有リソースやペリフェラルへの同時アクセスを防止します。 ロックしたタスク本人以外の誤った {\ttfamily \doxylink{classtk_1_1_mutex_ae8d5dfd5655b5aa54d63db6e0cf2f707}{unlock()}} は安全に無視されます。 C++ の {\ttfamily Basic\+Lockable} を満たしており、{\ttfamily std::\+lock\+\_\+guard} や {\ttfamily \doxylink{classtk_1_1_lock_guard}{tk::\+\+Lock\+Guard}} が利用可能です。
  21. \begin{DoxyCode}{0}
  22. \DoxyCodeLine{tk::Mutex\ mtx;}
  23. \DoxyCodeLine{}
  24. \DoxyCodeLine{\{}
  25. \DoxyCodeLine{\ \ \ \ tk::LockGuard<tk::Mutex>\ \doxymbox{\hyperlink{classtk_1_1_mutex_a7f5645bba55df2db263f92a954802c27}{lock}}(mtx);}
  26. \DoxyCodeLine{\ \ \ \ \textcolor{comment}{//\ クリティカルセクション...}}
  27. \DoxyCodeLine{\}\ \textcolor{comment}{//\ 自動でアンロック}}
  28. \end{DoxyCode}
  29. \label{classtk_1_1_mutex_doc-constructors}
  30. \Hypertarget{classtk_1_1_mutex_doc-constructors}
  31. \doxysubsection{Constructor \& Destructor Documentation}
  32. \Hypertarget{classtk_1_1_mutex_a8b17431db60f4ab48a3859b2ca722eb1}\index{tk::Mutex@{tk::Mutex}!Mutex@{Mutex}}
  33. \index{Mutex@{Mutex}!tk::Mutex@{tk::Mutex}}
  34. \doxysubsubsection{\texorpdfstring{Mutex()}{Mutex()}}
  35. {\footnotesize\ttfamily \label{classtk_1_1_mutex_a8b17431db60f4ab48a3859b2ca722eb1}
  36. tk::\+\+Mutex::\+\+Mutex (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [default]}}
  37. \label{classtk_1_1_mutex_doc-func-members}
  38. \Hypertarget{classtk_1_1_mutex_doc-func-members}
  39. \doxysubsection{Member Function Documentation}
  40. \Hypertarget{classtk_1_1_mutex_acf574e35540879481f1f6e5452a504ab}\index{tk::Mutex@{tk::Mutex}!is\_locked@{is\_locked}}
  41. \index{is\_locked@{is\_locked}!tk::Mutex@{tk::Mutex}}
  42. \doxysubsubsection{\texorpdfstring{is\_locked()}{is\_locked()}}
  43. {\footnotesize\ttfamily \label{classtk_1_1_mutex_acf574e35540879481f1f6e5452a504ab}
  44. bool tk::\+\+Mutex::\+is\+\_\+locked (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption}) const\hspace{0.3cm}{\ttfamily [inline]}}
  45. 現在ロックされているかどうかを判定 \Hypertarget{classtk_1_1_mutex_a7f5645bba55df2db263f92a954802c27}\index{tk::Mutex@{tk::Mutex}!lock@{lock}}
  46. \index{lock@{lock}!tk::Mutex@{tk::Mutex}}
  47. \doxysubsubsection{\texorpdfstring{lock()}{lock()}}
  48. {\footnotesize\ttfamily \label{classtk_1_1_mutex_a7f5645bba55df2db263f92a954802c27}
  49. void tk::\+\+Mutex::\+lock (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}
  50. ミューテックスをロックします (空くまでブロック待機)
  51. 他のタスクが保持している場合は、解放されるまで自タスクを {\ttfamily State::\+\+Blocked} にして休止します。 \Hypertarget{classtk_1_1_mutex_a666dd03fb22c5cb855e3145f76a58b9c}\index{tk::Mutex@{tk::Mutex}!try\_lock@{try\_lock}}
  52. \index{try\_lock@{try\_lock}!tk::Mutex@{tk::Mutex}}
  53. \doxysubsubsection{\texorpdfstring{try\_lock()}{try\_lock()}}
  54. {\footnotesize\ttfamily \label{classtk_1_1_mutex_a666dd03fb22c5cb855e3145f76a58b9c}
  55. bool tk::\+\+Mutex::\+try\+\_\+lock (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}
  56. ミューテックスのロックを試みます (ノンブロッキング)
  57. \begin{DoxyReturn}{Returns}
  58. true ロック獲得成功
  59. false 他のタスクが保持しているため獲得失敗 (ブロックせず即座に復帰)
  60. \end{DoxyReturn}
  61. \Hypertarget{classtk_1_1_mutex_ae8d5dfd5655b5aa54d63db6e0cf2f707}\index{tk::Mutex@{tk::Mutex}!unlock@{unlock}}
  62. \index{unlock@{unlock}!tk::Mutex@{tk::Mutex}}
  63. \doxysubsubsection{\texorpdfstring{unlock()}{unlock()}}
  64. {\footnotesize\ttfamily \label{classtk_1_1_mutex_ae8d5dfd5655b5aa54d63db6e0cf2f707}
  65. void tk::\+\+Mutex::\+unlock (\begin{DoxyParamCaption}{}{}\end{DoxyParamCaption})\hspace{0.3cm}{\ttfamily [inline]}}
  66. ミューテックスのロックを解除します
  67. ロックを保持しているタスク本人だけが解除できます。 待機中のタスクが存在する場合、最も優先度が高いタスクを 1 つ起床させます。
  68. The documentation for this class was generated from the following file:\begin{DoxyCompactItemize}
  69. \item
  70. C:\+/\+\+Users/\+yoneda/\+\+Documents/\+\+Pico\+\_\+\+Projects/\+tinykernel/\+tinykernel/\+include/\+tinykernel/\doxymbox{\hyperlink{sync_8hpp}{sync.\+hpp}}\end{DoxyCompactItemize}