2 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
8 * http://www.apache.org/licenses/LICENSE-2.0
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
17 ///////////////////////////////////////////////////////////////////////////////
18 /// \ingroup tag_NSFramework
19 /// \brief Application framework's core structures and data types.
23 ///////////////////////////////////////////////////////////////////////////////
26 * @file frameworkunified_multithreading.h
27 * @brief \~english Application framework's core structures and data types.
30 /** @addtogroup BaseSystem
33 /** @addtogroup native_service
37 /** @addtogroup framework_unified
38 * @ingroup native_service
41 /** @addtogroup framework
42 * @ingroup native_service
45 #ifndef __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__ // NOLINT (build/header_guard)
46 #define __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__
48 #include <native_service/frameworkunified_framework_types.h>
50 #define INHERIT_PARENT_THREAD_PRIO -100
52 ////////////////////////////////////////////////////////////////////////////////////////////
53 /// \ingroup FrameworkunifiedCreateChildThread
54 /// \~english @par Brief
55 /// Create child thread and dispatcher for child thread, and initialize it
56 /// \~english @param [in] hApp
57 /// HANDLE - Handle for Application of parent thread
58 /// \~english @param [in] childName
59 /// PCSTR - Child thread name
60 /// \~english @param [in] CbInitialize
61 /// CbFuncPtr - Pointer to the callback function for initializing child thread
62 /// \~english @param [in] CbShutdown
63 /// CbFuncPtr - Pointer to the callback function for stopping child thread
64 /// \~english @retval HANDLE handle for communicate with child thread
65 /// \~english @retval NULL Failure to get HANDLE
66 /// \~english @par Prerequisite
67 /// - Generation/Initialization of Dispatcher for the Application
68 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
69 /// \~english @par Change of internal state
70 /// - Change of internal state according to the API does not occur.
71 /// \~english @par Conditions of processing failure
72 /// - HANDLE specified in the argument (hApp) is NULL. [NULL]
73 /// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
74 /// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
75 /// - Callback function pointer specified in the argument (CbInitialize, CbShutdown) is NULL. [NULL]
76 /// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
77 /// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
78 /// - Failed to create child thread (pthread_create). [NULL]
79 /// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
80 /// - Can not be acquired memory for message queue name(malloc). [NULL]
81 /// - Failed to open message queue(mq_open). [NULL]
82 /// \~english @par Detail
83 /// This API creates child thread and returns handle for communicate with child thread.\n
84 /// Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
85 /// It starts to mainloop that receives request or notification,
86 /// and runs registered callback to dispatcher for child thread.
87 /// \~english @par Classification
89 /// \~english @par Type
92 /// FrameworkunifiedDestroyChildThread
93 ////////////////////////////////////////////////////////////////////////////////////////////
94 HANDLE FrameworkunifiedCreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr CbShutdown);
96 ////////////////////////////////////////////////////////////////////////////////////////////
97 /// \ingroup FrameworkunifiedCreateChildThreadWithPriority
98 /// \~english @par Brief
99 /// Create child thread with specified priority and dispatcher for child thread, and initialize it
100 /// \~english @param [in] hApp
101 /// HANDLE - Handle for Application of parent thread
102 /// \~english @param [in] childName
103 /// PCSTR - Child thread name
104 /// \~english @param [in] CbInitialize
105 /// CbFuncPtr - Pointer to the callback function for initializing child thread
106 /// \~english @param [in] CbShutdown
107 /// CbFuncPtr - Pointer to the callback function for stopping child thread
108 /// \~english @param [in] schedPrio
109 /// SI_32 - priority of child thread
110 /// (If INHERIT_PARENT_THREAD_PRIO specified, inherit from parent thread priority)
111 /// \~english @retval HANDLE handle for communicate with child thread
112 /// \~english @retval NULL Failure to get HANDLE
113 /// \~english @par Prerequisite
114 /// - Generation/Initialization of Dispatcher for the Application
115 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
116 /// \~english @par Change of internal state
117 /// - Change of internal state according to the API does not occur.
118 /// \~english @par Conditions of processing failure
119 /// - HANDLE specified in the argument (hApp) is NULL. [NULL]
120 /// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
121 /// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
122 /// - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
123 /// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
124 /// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
125 /// - Failed to create child thread (pthread_create). [NULL]
126 /// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
127 /// - Can not be acquired memory for message queue name(malloc). [NULL]
128 /// - Failed to open message queue(mq_open). [NULL]
129 /// \~english @par Detail
130 /// This API creates child thread with specified priority(schedPrio) and
131 /// returns handle for communicate with child thread.\n
132 /// The thread scheduling policy of generated child thread is fixed to first in-first out scheduling
133 /// (eFrameworkunifiedSchedPolicyFIFO).\n
134 /// Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
135 /// It starts to mainloop that receives request or notification,
136 /// and runs registered callback to dispatcher for child thread.\n
138 /// \~english @par Classification
140 /// \~english @par Type
143 /// FrameworkunifiedDestroyChildThread
144 ////////////////////////////////////////////////////////////////////////////////////////////
145 HANDLE FrameworkunifiedCreateChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
146 , CbFuncPtr CbShutdown, SI_32 schedPrio);
148 ////////////////////////////////////////////////////////////////////////////////////////////
149 /// \ingroup FrameworkunifiedCreateDispatcherChild
150 /// \~english @par Breif
151 /// Creates and initializes a handle for the child thread's application
152 /// \~english @param [out] hChildApp
153 /// HANDLE & - A handle for the child thread's application
154 /// \~english @param [in] childName
155 /// PCSTR - Child thread name
156 /// \~english @param [in] parentName
157 /// PCSTR - Parent thread name
158 /// \~english @retval eFrameworkunifiedStatusOK succss
159 /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
160 /// \~english @retval eFrameworkunifiedStatusNullPointer Framework generation failure
161 /// \~english @par Prerequisite
162 /// - A child thread has been created.
163 /// \~english @par Change of internal state
164 /// - The internal state is not changed.
165 /// \~english @par Conditions of processing failure
166 /// - If the childName to the child thread name of the application specified in the arguments is NULL [eFrameworkunifiedStatusInvldParam]
167 /// - If the parentName to the parent thread name of the application specified in the arguments is NULL [eFrameworkunifiedStatusInvldParam]
168 /// - When the parent thread name (parentName) of the application specified in the arguments exceeds 16 bytes [eFrameworkunifiedStatusInvldParam]
169 /// - When the normalized message queue name from the childName specified in the arguments exceeds 16 bytes [eFrameworkunifiedStatusNullPointer]
170 /// - Failed to open a message queue (mq_open) [eFrameworkunifiedStatusNullPointer]
171 /// - When acquisition (malloc) of the message queue management information area fails [eFrameworkunifiedStatusNullPointer]
172 /// - If the creation (socket, bind, listen) of sockets for error monitoring fails [eFrameworkunifiedStatusFail]
173 /// - When a message queue is created with the name of an already registered thread [eFrameworkunifiedStatusFail]
174 /// - Failed to create epoll instances (epoll_create1) [eFrameworkunifiedStatusInvldHandle]
175 /// - Failed to register Dispatcher message queue descriptor for epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
176 /// - Failed to create file descriptor for receiving events to Dispatcher (eventfd) [eFrameworkunifiedStatusFail]
177 /// - Failed to register file descriptor for receiving Dispatcher events to epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
178 /// - Failed to register socket for monitoring Dispatcher error in epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
179 /// \~english @par Detail
180 /// This API creates a handle for the application of the child thread, initializes it, and returns the handle.
181 /// \~english @par Classification
183 /// \~english @par Type
187 /// \~english @par Brief
188 /// Create and initialize an threads dispatcher.
190 /// \~english \param [out] hChildApp
191 /// HANDLE& - Reference of application handle
192 /// \~english \param [in] childName
193 /// PCSTR - create thread name
194 /// \~english \param [in] parentName
195 /// PCSTR - parent thread name
197 /// \~english \return status
198 /// EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if Success
199 /// possible errors from call CreateDispatcher
200 ////////////////////////////////////////////////////////////////////////////////////////////
201 EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherChild(HANDLE &hChildApp, PCSTR childName, PCSTR parentName); // NOLINT (readability/nolint)
203 ////////////////////////////////////////////////////////////////////////////////////////////
204 /// \ingroup FrameworkunifiedCreateChildThreadWithAttribute
205 /// \~english @par Brief
206 /// Create child thread with specified thread attributes and dispatcher for child thread, and initialize it
207 /// \~english @param [in] hApp
208 /// HANDLE - Handle for Application of parent thread
209 /// \~english @param [in] childName
210 /// PCSTR - Child thread name
211 /// \~english @param [in] CbInitialize
212 /// CbFuncPtr - Pointer to the callback function for initializing child thread
213 /// \~english @param [in] CbShutdown
214 /// CbFuncPtr - Pointer to the callback function for stopping child thread
215 /// \~english @param [out] attr
216 /// FrameworkunifiedChildThreadAttr* - Pointer to thread attributes
218 /// FrameworkunifiedChildThreadAttr Structure
220 /// typedef struct _FrameworkunifiedChildThreadAttr
222 /// EFrameworkunifiedSchedPolicy schedPolicy; // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
223 /// SI_32 schedPriority; // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
224 /// } FrameworkunifiedChildThreadAttr;
227 /// enum EFrameworkunifiedSchedPolicy Variable
229 /// typedef enum _EFrameworkunifiedSchedPolicy {
230 /// eFrameworkunifiedSchedPolicyInherit = 0, // Inherit from parent thread.
231 /// eFrameworkunifiedSchedPolicyTSS, // Time Sharing System scheduling
232 /// eFrameworkunifiedSchedPolicyFIFO, // First in-first out scheduling
233 /// eFrameworkunifiedSchedPolicyRR, // Round-robin scheduling
234 /// eFrameworkunifiedSchedPolicyMAX // EFrameworkunifiedSchedPolicy Max(Not to be used.)
235 /// } EFrameworkunifiedSchedPolicy;
237 /// \~english @retval HANDLE handle for communicate with child thread
238 /// \~english @retval NULL Failure to get HANDLE
239 /// \~english @par Prerequisite
240 /// - Generation/Initialization of Dispatcher for the Application
241 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
242 /// \~english @par Change of internal state
243 /// - Change of internal state according to the API does not occur.
244 /// \~english @par Conditions of processing failure
245 /// - HANDLE specified in the argument (hApp) is NULL. [NULL]
246 /// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
247 /// - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
248 /// - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
249 /// - Thread attribute specified in the argument (attr) is NULL. [NULL]
250 /// - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
251 /// - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
252 /// - Failed to create child thread (pthread_create). [NULL]
253 /// - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
254 /// - Can not be acquired memory for message queue name(malloc). [NULL]
255 /// - Failed to open message queue(mq_open). [NULL]
256 /// \~english @par Detail
257 /// This API creates child thread with specified thread attributes(attr)
258 /// and returns handle for communicate with child thread.\n
259 /// Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
260 /// It starts to mainloop that receives request or notification,
261 /// and runs registered callback to dispatcher for child thread.
262 /// \~english @par Classification
264 /// \~english @par Type
267 /// FrameworkunifiedDestroyChildThread
268 ////////////////////////////////////////////////////////////////////////////////////////////
269 HANDLE FrameworkunifiedCreateChildThreadWithAttribute(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
270 , CbFuncPtr CbShutdown, const FrameworkunifiedChildThreadAttr *attr);
272 ////////////////////////////////////////////////////////////////////////////////////////////
273 /// \ingroup FrameworkunifiedCreateChildThreadAttrInit
274 /// \~english @par Brief
275 /// Initialize thread attribute object.
276 /// \~english @param [out] attr
277 /// FrameworkunifiedChildThreadAttr* - Pointer to thread attribute
279 /// FrameworkunifiedChildThreadAttr Structure
281 /// typedef struct _FrameworkunifiedChildThreadAttr
283 /// EFrameworkunifiedSchedPolicy schedPolicy; // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
284 /// SI_32 schedPriority; // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
285 /// } FrameworkunifiedChildThreadAttr;
288 /// enum EFrameworkunifiedSchedPolicy Variable
290 /// typedef enum _EFrameworkunifiedSchedPolicy {
291 /// eFrameworkunifiedSchedPolicyInherit = 0, // Inherit from parent thread.
292 /// eFrameworkunifiedSchedPolicyTSS, // Time Sharing System scheduling
293 /// eFrameworkunifiedSchedPolicyFIFO, // First in-first out scheduling
294 /// eFrameworkunifiedSchedPolicyRR, // Round-robin scheduling
295 /// eFrameworkunifiedSchedPolicyMAX // EFrameworkunifiedSchedPolicy Max(Not to be used.)
296 /// } EFrameworkunifiedSchedPolicy;
298 /// \~english @retval eFrameworkunifiedStatusOK Success
299 /// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
300 /// \~english @par Prerequisite
302 /// \~english @par Change of internal state
303 /// - Change of internal state according to the API does not occur.
304 /// \~english @par Conditions of processing failure
305 /// - the argument attr is NULL. [eFrameworkunifiedStatusNullPointer]
306 /// \~english @par Detail
307 /// This API initialize thread attribute (attr) by default value of NS framework.
308 /// \~english @par Classification
310 /// \~english @par Type
313 /// FrameworkunifiedCreateChildThreadWithAttribute
314 ////////////////////////////////////////////////////////////////////////////////////////////
315 EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr);
317 ////////////////////////////////////////////////////////////////////////////////////////////
318 /// \ingroup FrameworkunifiedCreateChildThreadAttrSetSched
319 /// \~english @par Brief
320 /// Initialize thread attribute object with specified value.
321 /// \~english @param [out] attr
322 /// FrameworkunifiedChildThreadAttr* - Pointer to thread attribute
323 /// \~english @param [in] policy
324 /// EFrameworkunifiedSchedPolicy - Thread shcheduling policy at thread start
325 /// \~english @param [in] priority
326 /// SI_32 - Thread priority at thread start
328 /// FrameworkunifiedChildThreadAttr Structure
330 /// typedef struct _FrameworkunifiedChildThreadAttr
332 /// EFrameworkunifiedSchedPolicy schedPolicy; // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
333 /// SI_32 schedPriority; // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
334 /// } FrameworkunifiedChildThreadAttr;
337 /// enum EFrameworkunifiedSchedPolicy Variable
339 /// typedef enum _EFrameworkunifiedSchedPolicy {
340 /// eFrameworkunifiedSchedPolicyInherit = 0, // Inherit from parent thread.
341 /// eFrameworkunifiedSchedPolicyTSS, // Time Sharing System scheduling
342 /// eFrameworkunifiedSchedPolicyFIFO, // First in-first out scheduling
343 /// eFrameworkunifiedSchedPolicyRR, // Round-robin scheduling
344 /// eFrameworkunifiedSchedPolicyMAX // EFrameworkunifiedSchedPolicy Max(Not to be used.)
345 /// } EFrameworkunifiedSchedPolicy;
347 /// \~english @retval eFrameworkunifiedStatusOK Success
348 /// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
349 /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
350 /// \~english @par Prerequisite
352 /// \~english @par Change of internal state
353 /// - Change of internal state according to the API does not occur.
354 /// \~english @par Conditions of processing failure
355 /// - the argument attr is NULL. [eFrameworkunifiedStatusNullPointer]
356 /// - the argument policy is out of range
357 /// (less than eFrameworkunifiedSchedPolicyInherit, over eFrameworkunifiedSchedPolicyMAX). [eFrameworkunifiedStatusInvldParam]
358 /// \~english @par Detail
359 /// This API initializes thread attribute object for child thread with specified value.\n
361 /// \~english @par Classification
364 /// FrameworkunifiedCreateChildThreadWithAttribute
365 ////////////////////////////////////////////////////////////////////////////////////////////
366 EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority);
368 ////////////////////////////////////////////////////////////////////////////////////////////
369 /// \ingroup FrameworkunifiedStartChildThread
370 /// \~english @par Brief
371 /// Send initialize request to the child thread.
372 /// \~english @param [in] hApp
373 /// HANDLE - Handle for Application of parent thread
374 /// \~english @param [in] hChildQ
375 /// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
376 /// \~english @param [in] length
377 /// UI_32 - Length of send message data
378 /// \~english @param [in] data
379 /// PCVOID - Pointer to message data
380 /// \~english @retval eFrameworkunifiedStatusOK Success
381 /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
382 /// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
383 /// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
384 /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
385 /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
386 /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
387 /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
388 /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
389 /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
390 /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
391 /// \~english @par Prerequisite
392 /// - Generation/Initialization of Dispatcher for the Application
393 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
394 /// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
395 /// \~english @par Change of internal state
396 /// - Change of internal state is depend on application implements.
397 /// \~english @par Conditions of processing failure
398 /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
399 /// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
400 /// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
401 /// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
402 /// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
403 /// - Thread name specified in the argument (hChildQ) is not appropriate
404 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
405 /// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
406 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
407 /// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
408 /// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
409 /// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
410 /// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
411 /// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
412 /// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
413 /// \~english @par Detail
414 /// This API sends initialize request to the child thread from parent thread.\n
415 /// Taking this request,
416 /// child thread runs callback function for initialize that specified when the thread create.
419 /// \~english @par Classification
421 /// \~english @par Type
424 /// FrameworkunifiedStopChildThread
425 ////////////////////////////////////////////////////////////////////////////////////////////
426 EFrameworkunifiedStatus FrameworkunifiedStartChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data);
428 ////////////////////////////////////////////////////////////////////////////////////////////
429 /// \ingroup FrameworkunifiedStopChildThread
430 /// \~english @par Brief
431 /// Send shutdown request to the child thread.
432 /// \~english @param [in] hApp
433 /// HANDLE - Handle for Application of parent thread
434 /// \~english @param [in] hChildQ
435 /// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
436 /// \~english @param [in] length
437 /// UI_32 - Length of send message data
438 /// \~english @param [in] data
439 /// PCVOID - Pointer to message data
440 /// \~english @retval eFrameworkunifiedStatusOK Success
441 /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
442 /// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
443 /// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
444 /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
445 /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
446 /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
447 /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
448 /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
449 /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
450 /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
451 /// \~english @par Prerequisite
452 /// - Generation/Initialization of Dispatcher for the Application
453 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
454 /// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
455 /// \~english @par Change of internal state
456 /// - Change of internal state is depend on application implements.
457 /// \~english @par Conditions of processing failure
458 /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
459 /// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
460 /// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
461 /// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
462 /// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
463 /// - Thread name specified in the argument (hChildQ) is not appropriate
464 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
465 /// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
466 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
467 /// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
468 /// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
469 /// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
470 /// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
471 /// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
472 /// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
473 /// \~english @par Detail
474 /// This API sends shutdown request to the child thread.\n
475 /// Taking this request,
476 /// child thread runs callback function for shutdown that specified when the thread create.\n
477 /// This API does not terminate child thread.
478 /// Use FrameworkunifiedDestroyChildThread to terminate child thread from parent thread.
481 /// \~english @par Classification
484 /// FrameworkunifiedStartChildThread FrameworkunifiedDestroyChildThread
485 ////////////////////////////////////////////////////////////////////////////////////////////
486 EFrameworkunifiedStatus FrameworkunifiedStopChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data);
488 ////////////////////////////////////////////////////////////////////////////////////////////
489 /// \ingroup FrameworkunifiedDestroyChildThread
490 /// \~english @par Brief
491 /// Terminate child thread.
492 /// \~english @param [in] hApp
493 /// HANDLE - Handle for Application of parent thread
494 /// \~english @param [in] hChildQ
495 /// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
496 /// \~english @retval eFrameworkunifiedStatusOK Success
497 /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
498 /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
499 /// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
500 /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
501 /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
502 /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
503 /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
504 /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
505 /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
506 /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
507 /// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
508 /// \~english @retval eFrameworkunifiedStatusThreadSelfJoin Self thread specified
509 /// \~english @par Prerequisite
510 /// - Generation/Initialization of Dispatcher for the Application
511 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
512 /// - Generation/Initialization of Dispatcher for the child thread
513 /// (FrameworkunifiedCreateChildThread, etc.) has been done.
514 /// \~english @par Change of internal state
515 /// - Change of internal state is depend on application implements.
516 /// \~english @par Conditions of processing failure
517 /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
518 /// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
519 /// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldParam]
520 /// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
521 /// - Thread name specified in the argument (hChildQ) is not appropriate
522 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
523 /// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
524 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
525 /// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
526 /// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
527 /// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
528 /// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
529 /// - Message data size is invalid. [eFrameworkunifiedStatusInvldBufSize]
530 /// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
531 /// - Child thread is invalid (thread exit or invalid) [eFrameworkunifiedStatusInvldHandle]
532 /// - Another thread is already waiting to join with this child thread. [eFrameworkunifiedStatusInvldParam]
533 /// - Already child thread is in termination process [eFrameworkunifiedStatusInvldParam]
534 /// - Thread specified in argument is self thread. [eFrameworkunifiedStatusThreadSelfJoin]
535 /// - Failed to close message queue specified in the argument (hChildQ). [eFrameworkunifiedStatusInvldHandle]
536 /// \~english @par Detail
537 /// This API sends terminate request to child thread , and waits to terminate child thread.\n
538 /// Taking this request, child thread terminates itself.\n
539 /// After child thread terminates, parent thread destroys handle for communicate with child thread.
540 /// \~english @par Classification
542 /// \~english @see FrameworkunifiedCreateChildThread FrameworkunifiedCreateChildThreadWithAttribute FrameworkunifiedCreateChildThreadWithPriority
543 ////////////////////////////////////////////////////////////////////////////////////////////
544 EFrameworkunifiedStatus FrameworkunifiedDestroyChildThread(HANDLE hApp, HANDLE hChildQ);
546 ////////////////////////////////////////////////////////////////////////////////////////////
547 /// \ingroup FrameworkunifiedSendChild
548 /// \~english @par Brief
549 /// Send a message to the child thread.
550 /// \~english @param [in] hApp
551 /// HANDLE - Handle for Application of parent thread
552 /// \~english @param [in] hChildQ
553 /// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
554 /// \~english @param [in] iCmd
555 /// UI_32 - Command of message
556 /// \~english @param [in] length
557 /// UI_32 - Length of send message data
558 /// \~english @param [in] data
559 /// PCVOID - Pointer to message data
560 /// \~english @retval eFrameworkunifiedStatusOK Success
561 /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
562 /// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
563 /// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
564 /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
565 /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
566 /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
567 /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
568 /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
569 /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
570 /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
571 /// \~english @par Prerequisite
572 /// - Generation/Initialization of Dispatcher for the Application
573 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
574 /// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
575 /// \~english @par Change of internal state
576 /// - Change of internal state according to the API does not occur.
577 /// \~english @par Conditions of processing failure
578 /// - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
579 /// - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
580 /// - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
581 /// - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
582 /// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
583 /// - Thread name specified in the argument (hChildQ) is not appropriate
584 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
585 /// - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
586 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
587 /// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
588 /// - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
589 /// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
590 /// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
591 /// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
592 /// - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
593 /// \~english @par Detail
594 /// This API sends a message to the child thread from parent thread.\n
595 /// This API is available only from parent thread.
598 /// \~english @par Classification
600 /// \~english @par Type
603 /// FrameworkunifiedSendParent
604 ////////////////////////////////////////////////////////////////////////////////////////////
605 EFrameworkunifiedStatus FrameworkunifiedSendChild(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd, UI_32 length, PCVOID data);
607 ////////////////////////////////////////////////////////////////////////////////////////////
608 /// \ingroup FrameworkunifiedSendParent
609 /// \~english @par Brief
610 /// Send a message to the parent thread.
611 /// \~english @param [in] hChildApp
612 /// HANDLE - Handle for Application of child thread(get as argument of callback function)
613 /// \~english @param [in] iCmd
614 /// UI_32 - Command of message
615 /// \~english @param [in] length
616 /// UI_32 - Length of send message data
617 /// \~english @param [in] data
618 /// PCVOID - Pointer to message data
619 /// \~english @retval eFrameworkunifiedStatusOK Success
620 /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
621 /// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
622 /// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
623 /// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
624 /// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
625 /// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
626 /// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
627 /// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
628 /// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
629 /// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
630 /// \~english @par Prerequisite
631 /// - Generation/Initialization of Dispatcher for the Application
632 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
633 /// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
634 /// \~english @par Change of internal state
635 /// - Change of internal state according to the API does not occur.
636 /// \~english @par Conditions of processing failure
637 /// - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
638 /// - HANDLE specified in the argument (hChildApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
639 /// - Message queue for parent thread in HANDLE (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
640 /// - Message queue for parent thread in HANDLE (hChildApp) is not appropriate
641 /// (which is invalid). [eFrameworkunifiedStatusInvldHandle]
642 /// - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
643 /// - Thread name specified in the argument (hChildApp) is not appropriate
644 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
645 /// - The name of message queue for parent thread specified in the argument (hChildApp) is not appropriate
646 /// (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
647 /// - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
648 /// - Type of message queue to parent thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
649 /// - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
650 /// - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
651 /// - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
652 /// - Any errors occur during the transmission of message to the parent thread. [eFrameworkunifiedStatusFail]
653 /// \~english @par Detail
654 /// This API sends a message to the parent thread from child thread.\n
655 /// This API is available only from child thread.
658 /// \~english @par Classification
660 /// \~english @par Type
663 /// FrameworkunifiedSendChild
664 ////////////////////////////////////////////////////////////////////////////////////////////
665 EFrameworkunifiedStatus FrameworkunifiedSendParent(HANDLE hChildApp, UI_32 iCmd, UI_32 length, PCVOID data);
667 ////////////////////////////////////////////////////////////////////////////////////////////
668 /// \ingroup FrameworkunifiedJoinChild
669 /// \~english @par Brief
670 /// Wait for child thread terminates.
671 /// \~english @param [in] hChildApp
672 /// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
673 /// \~english @retval eFrameworkunifiedStatusOK Success
674 /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
675 /// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
676 /// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
677 /// \~english @retval eFrameworkunifiedStatusThreadSelfJoin Self thread specified
678 /// \~english @retval eFrameworkunifiedStatusFail thread exit or invalid
679 /// \~english @par Prerequisite
680 /// - Generation/Initialization of Dispatcher for the Application
681 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
682 /// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
683 /// \~english @par Change of internal state
684 /// - Change of internal state according to the API does not occur.
685 /// \~english @par Conditions of processing failure
686 /// - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
687 /// - HANDLE specified in the argument (hChildApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
688 /// - Child thread is invalid (thread exit or invalid) [eFrameworkunifiedStatusFail]
689 /// - Another thread is already waiting to join with this child thread. [eFrameworkunifiedStatusInvldParam]
690 /// - Already child thread is in termination process [eFrameworkunifiedStatusInvldParam]
691 /// - Thread specified in argument is self thread. [eFrameworkunifiedStatusThreadSelfJoin]
692 /// \~english @par Detail
693 /// It waits for terminate of child thread it was created by FrameworkunifiedCreateChildThread
694 /// (or similar one) in the parent thread.\n
695 /// This API blocks the calling thread until child thread terminates.\n
696 /// This API does not terminate child thread.
697 /// Use FrameworkunifiedDestroyChildThread to terminate child thread from parent thread.
698 /// \~english @par Classification
701 /// FrameworkunifiedCreateChildThread, FrameworkunifiedCreateChildThreadWithPriority, FrameworkunifiedDestroyChildThread
702 ////////////////////////////////////////////////////////////////////////////////////////////
703 EFrameworkunifiedStatus FrameworkunifiedJoinChild(HANDLE hChildApp);
705 ////////////////////////////////////////////////////////////////////////////////////////////
706 /// \ingroup FrameworkunifiedGetChildThreadPriority
707 /// \~english @par Brief
708 /// Get the child thread priority.
709 /// \~english @param [in] hChildApp
710 /// HANDLE - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
711 /// \~english @param [out] threadPrio
712 /// PSI_32 - Dispatcher file descriptor
713 /// \~english @retval eFrameworkunifiedStatusOK Success
714 /// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
715 /// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
716 /// \~english @retval eFrameworkunifiedStatusFault Error occured during function
717 /// \~english @par Prerequisite
718 /// - Generation/Initialization of Dispatcher for the Application
719 /// (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
720 /// - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
721 /// \~english @par Change of internal state
722 /// - Change of internal state according to the API does not occur.
723 /// \~english @par Conditions of processing failure
724 /// - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
725 /// - HANDLE specified in the argument (hChildApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
726 /// - child thread priority in the argument (threadPrio) is NULL. [eFrameworkunifiedStatusInvldParam]
727 /// - Failed to get child thread priority (pthread_getschedparam). [eFrameworkunifiedStatusFault]
728 /// - If child threads are inalid or already terminated. [eFrameworkunifiedStatusThreadNotExist]
729 /// \~english @par Detail
730 /// This API set the child thread priority generated by FrameworkunifiedCreateChildThread to argument threadPrio.
731 /// Use to get child thread priority from parent thread.
732 /// \~english @par Classification
734 /// \~english @par Type
737 /// FrameworkunifiedCreateChildThread, FrameworkunifiedCreateChildThreadWithPriority
738 ////////////////////////////////////////////////////////////////////////////////////////////
739 EFrameworkunifiedStatus FrameworkunifiedGetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio);
740 #endif // __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__ NOLINT (build/header_guard)