summaryrefslogtreecommitdiffstats
path: root/nsframework/framework_unified/client/include/native_service/frameworkunified_multithreading.h
blob: b943596912893dc244ba6275cc5f1076c7699d77 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
/*
 * @copyright Copyright (c) 2016-2020 TOYOTA MOTOR CORPORATION.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

///////////////////////////////////////////////////////////////////////////////
/// \ingroup  tag_NSFramework
/// \brief    Application framework's core structures and data types.
///
///
///
///////////////////////////////////////////////////////////////////////////////
//@{
/**
 * @file frameworkunified_multithreading.h
 * @brief \~english Application framework's core structures and data types.
 *
 */
/** @addtogroup BaseSystem
 *  @{
 */
/** @addtogroup native_service
 *  @ingroup BaseSystem
 *  @{
 */
/** @addtogroup framework_unified
 *  @ingroup native_service
 *  @{
 */
/** @addtogroup framework
 *  @ingroup native_service
 *  @{
 */
#ifndef __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__  // NOLINT  (build/header_guard)
#define __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__

#include <native_service/frameworkunified_framework_types.h>

#define INHERIT_PARENT_THREAD_PRIO -100

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedCreateChildThread
/// \~english @par Brief
///        Create child thread and dispatcher for child thread, and initialize it
/// \~english @param [in] hApp
///        HANDLE   - Handle for Application of parent thread
/// \~english @param [in] childName
///        PCSTR   - Child thread name
/// \~english @param [in] CbInitialize
///        CbFuncPtr   - Pointer to the callback function for initializing child thread
/// \~english @param [in] CbShutdown
///        CbFuncPtr   - Pointer to the callback function for stopping child thread
/// \~english @retval HANDLE handle for communicate with child thread
/// \~english @retval NULL  Failure to get HANDLE
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hApp) is NULL. [NULL]
///        - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
///        - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
///        - Callback function pointer specified in the argument (CbInitialize, CbShutdown) is NULL. [NULL]
///        - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
///        - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
///        - Failed to create child thread (pthread_create). [NULL]
///        - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
///        - Can not be acquired memory for message queue name(malloc). [NULL]
///        - Failed to open message queue(mq_open). [NULL]
/// \~english @par Detail
///        This API creates child thread and returns handle for communicate with child thread.\n
///        Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
///        It starts to mainloop that receives request or notification,
///        and runs registered callback to dispatcher for child thread.
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        FrameworkunifiedDestroyChildThread
////////////////////////////////////////////////////////////////////////////////////////////
HANDLE FrameworkunifiedCreateChildThread(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize, CbFuncPtr CbShutdown);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedCreateChildThreadWithPriority
/// \~english @par Brief
///        Create child thread with specified priority and dispatcher for child thread, and initialize it
/// \~english @param [in] hApp
///        HANDLE   - Handle for Application of parent thread
/// \~english @param [in] childName
///        PCSTR   - Child thread name
/// \~english @param [in] CbInitialize
///        CbFuncPtr   - Pointer to the callback function for initializing child thread
/// \~english @param [in] CbShutdown
///        CbFuncPtr   - Pointer to the callback function for stopping child thread
/// \~english @param [in] schedPrio
///        SI_32   - priority of child thread
///                  (If INHERIT_PARENT_THREAD_PRIO specified, inherit from parent thread priority)
/// \~english @retval HANDLE handle for communicate with child thread
/// \~english @retval NULL  Failure to get HANDLE
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hApp) is NULL. [NULL]
///        - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
///        - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
///        - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
///        - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
///        - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
///        - Failed to create child thread (pthread_create). [NULL]
///        - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
///        - Can not be acquired memory for message queue name(malloc). [NULL]
///        - Failed to open message queue(mq_open). [NULL]
/// \~english @par Detail
///        This API creates child thread with specified priority(schedPrio) and
///        returns handle for communicate with child thread.\n
///        The thread scheduling policy of generated child thread is fixed to first in-first out scheduling
///        (eFrameworkunifiedSchedPolicyFIFO).\n
///        Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
///        It starts to mainloop that receives request or notification,
///        and runs registered callback to dispatcher for child thread.\n
///        \n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        FrameworkunifiedDestroyChildThread
////////////////////////////////////////////////////////////////////////////////////////////
HANDLE FrameworkunifiedCreateChildThreadWithPriority(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
                                        , CbFuncPtr CbShutdown, SI_32 schedPrio);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedCreateDispatcherChild
/// \~english @par Breif
///        Creates and initializes a handle for the child thread's application
/// \~english @param [out] hChildApp
///        HANDLE &  -  A handle for the child thread's application
/// \~english @param [in] childName
///        PCSTR   - Child thread name
/// \~english @param [in] parentName
///        PCSTR   - Parent thread name
/// \~english @retval eFrameworkunifiedStatusOK succss
/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
/// \~english @retval eFrameworkunifiedStatusNullPointer Framework generation failure
/// \~english @par Prerequisite
///       - A child thread has been created.
/// \~english @par Change of internal state
///       - The internal state is not changed.
/// \~english @par Conditions of processing failure
///       - If the childName to the child thread name of the application specified in the arguments is NULL [eFrameworkunifiedStatusInvldParam]
///       - If the parentName to the parent thread name of the application specified in the arguments is NULL [eFrameworkunifiedStatusInvldParam]
///       - When the parent thread name (parentName) of the application specified in the arguments exceeds 16 bytes [eFrameworkunifiedStatusInvldParam]
///       - When the normalized message queue name from the childName specified in the arguments exceeds 16 bytes [eFrameworkunifiedStatusNullPointer]
///       - Failed to open a message queue (mq_open) [eFrameworkunifiedStatusNullPointer]
///       - When acquisition (malloc) of the message queue management information area fails [eFrameworkunifiedStatusNullPointer]
///       - If the creation (socket, bind, listen) of sockets for error monitoring fails [eFrameworkunifiedStatusFail]
///       - When a message queue is created with the name of an already registered thread [eFrameworkunifiedStatusFail]
///       - Failed to create epoll instances (epoll_create1) [eFrameworkunifiedStatusInvldHandle]
///       - Failed to register Dispatcher message queue descriptor for epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
///       - Failed to create file descriptor for receiving events to Dispatcher (eventfd) [eFrameworkunifiedStatusFail]
///       - Failed to register file descriptor for receiving Dispatcher events to epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
///       - Failed to register socket for monitoring Dispatcher error in epoll instances (epoll_ctl) [eFrameworkunifiedStatusFail]
/// \~english @par Detail
///       This API creates a handle for the application of the child thread, initializes it, and returns the handle.
/// \~english @par Classification
///          Public
/// \~english @par Type
///        Open Close
/// \~english @see
///
/// \~english @par Brief
/// Create and initialize an threads dispatcher.
///
/// \~english \param [out] hChildApp
///         HANDLE& - Reference of application handle
/// \~english \param [in] childName
///         PCSTR - create thread name
/// \~english \param [in] parentName
///         PCSTR - parent thread name
///
/// \~english \return status
///         EFrameworkunifiedStatus - eFrameworkunifiedStatusOK if Success
///         possible errors from call CreateDispatcher
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedCreateDispatcherChild(HANDLE &hChildApp, PCSTR childName, PCSTR parentName);  // NOLINT  (readability/nolint)

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedCreateChildThreadWithAttribute
/// \~english @par Brief
///        Create child thread with specified thread attributes and dispatcher for child thread, and initialize it
/// \~english @param [in] hApp
///        HANDLE   - Handle for Application of parent thread
/// \~english @param [in] childName
///        PCSTR   - Child thread name
/// \~english @param [in] CbInitialize
///        CbFuncPtr   - Pointer to the callback function for initializing child thread
/// \~english @param [in] CbShutdown
///        CbFuncPtr   - Pointer to the callback function for stopping child thread
/// \~english @param [out] attr
///        FrameworkunifiedChildThreadAttr*   - Pointer to thread attributes
/// \~english @par
///        FrameworkunifiedChildThreadAttr Structure
/// \~english @code
///                 typedef struct _FrameworkunifiedChildThreadAttr
///                 {
///                   EFrameworkunifiedSchedPolicy schedPolicy;  // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
///                   SI_32 schedPriority;          // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
///                 } FrameworkunifiedChildThreadAttr;
///            @endcode
/// \~english @par
///        enum EFrameworkunifiedSchedPolicy Variable
/// \~english @code
///                 typedef enum _EFrameworkunifiedSchedPolicy {
///                   eFrameworkunifiedSchedPolicyInherit = 0,  // Inherit from parent thread.
///                   eFrameworkunifiedSchedPolicyTSS,          // Time Sharing System scheduling
///                   eFrameworkunifiedSchedPolicyFIFO,         // First in-first out scheduling
///                   eFrameworkunifiedSchedPolicyRR,           // Round-robin scheduling
///                   eFrameworkunifiedSchedPolicyMAX           // EFrameworkunifiedSchedPolicy Max(Not to be used.)
///                 } EFrameworkunifiedSchedPolicy;
///            @endcode
/// \~english @retval HANDLE handle for communicate with child thread
/// \~english @retval NULL  Failure to get HANDLE
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hApp) is NULL. [NULL]
///        - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [NULL]
///        - Message queue name specified in the argument (childName) is not appropriate (NULL, over 16byte). [NULL]
///        - Callback function pointer specified in the argument (CbInitialize,CbShutdown) is NULL. [NULL]
///        - Thread attribute specified in the argument (attr) is NULL. [NULL]
///        - Failed to set the inherit-scheduler attribute (pthread_attr_setinheritsched) of the child thread. [NULL]
///        - Failed to initialize barrier object (pthread_barrier_init) for thread synchronization. [NULL]
///        - Failed to create child thread (pthread_create). [NULL]
///        - Failed to wait thread synchronization (pthread_barrier_wait). [NULL]
///        - Can not be acquired memory for message queue name(malloc). [NULL]
///        - Failed to open message queue(mq_open). [NULL]
/// \~english @par Detail
///        This API creates child thread with specified thread attributes(attr)
///        and returns handle for communicate with child thread.\n
///        Generated child thread creates dispatcher for itself, and initializes the dispatcher. \n
///        It starts to mainloop that receives request or notification,
///        and runs registered callback to dispatcher for child thread.
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        FrameworkunifiedDestroyChildThread
////////////////////////////////////////////////////////////////////////////////////////////
HANDLE FrameworkunifiedCreateChildThreadWithAttribute(HANDLE hApp, PCSTR childName, CbFuncPtr CbInitialize
                                         , CbFuncPtr CbShutdown, const FrameworkunifiedChildThreadAttr *attr);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedCreateChildThreadAttrInit
/// \~english @par Brief
///        Initialize thread attribute object.
/// \~english @param [out] attr
///        FrameworkunifiedChildThreadAttr*   - Pointer to thread attribute
/// \~english @par
///        FrameworkunifiedChildThreadAttr Structure
/// \~english @code
///                 typedef struct _FrameworkunifiedChildThreadAttr
///                 {
///                   EFrameworkunifiedSchedPolicy schedPolicy;  // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
///                   SI_32 schedPriority;          // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
///                 } FrameworkunifiedChildThreadAttr;
///            @endcode
/// \~english @par
///        enum EFrameworkunifiedSchedPolicy Variable
/// \~english @code
///                 typedef enum _EFrameworkunifiedSchedPolicy {
///                   eFrameworkunifiedSchedPolicyInherit = 0,  // Inherit from parent thread.
///                   eFrameworkunifiedSchedPolicyTSS,          // Time Sharing System scheduling
///                   eFrameworkunifiedSchedPolicyFIFO,         // First in-first out scheduling
///                   eFrameworkunifiedSchedPolicyRR,           // Round-robin scheduling
///                   eFrameworkunifiedSchedPolicyMAX           // EFrameworkunifiedSchedPolicy Max(Not to be used.)
///                 } EFrameworkunifiedSchedPolicy;
///            @endcode
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
/// \~english @par Prerequisite
///        None
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - the argument attr is NULL. [eFrameworkunifiedStatusNullPointer]
/// \~english @par Detail
///        This API initialize thread attribute (attr) by default value of NS framework.
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        FrameworkunifiedCreateChildThreadWithAttribute
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrInit(FrameworkunifiedChildThreadAttr *attr);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedCreateChildThreadAttrSetSched
/// \~english @par Brief
///        Initialize thread attribute object with specified value.
/// \~english @param [out] attr
///        FrameworkunifiedChildThreadAttr*   - Pointer to thread attribute
/// \~english @param [in] policy
///        EFrameworkunifiedSchedPolicy   - Thread shcheduling policy at thread start
/// \~english @param [in] priority
///        SI_32   - Thread priority at thread start
/// \~english @par
///        FrameworkunifiedChildThreadAttr Structure
/// \~english @code
///                 typedef struct _FrameworkunifiedChildThreadAttr
///                 {
///                   EFrameworkunifiedSchedPolicy schedPolicy;  // Thread scheduling policy(Default is eFrameworkunifiedSchedPolicyInherit)
///                   SI_32 schedPriority;          // Thread priority(Default is INHERIT_PARENT_THREAD_PRIO)
///                 } FrameworkunifiedChildThreadAttr;
///            @endcode
/// \~english @par
///        enum EFrameworkunifiedSchedPolicy Variable
/// \~english @code
///                 typedef enum _EFrameworkunifiedSchedPolicy {
///                   eFrameworkunifiedSchedPolicyInherit = 0,  // Inherit from parent thread.
///                   eFrameworkunifiedSchedPolicyTSS,          // Time Sharing System scheduling
///                   eFrameworkunifiedSchedPolicyFIFO,         // First in-first out scheduling
///                   eFrameworkunifiedSchedPolicyRR,           // Round-robin scheduling
///                   eFrameworkunifiedSchedPolicyMAX           // EFrameworkunifiedSchedPolicy Max(Not to be used.)
///                 } EFrameworkunifiedSchedPolicy;
///            @endcode
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusNullPointer NULL pointer specified
/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
/// \~english @par Prerequisite
///       None
/// \~english @par Change of internal state
///       - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///       - the argument attr is NULL. [eFrameworkunifiedStatusNullPointer]
///       - the argument policy is out of range
///         (less than eFrameworkunifiedSchedPolicyInherit, over eFrameworkunifiedSchedPolicyMAX). [eFrameworkunifiedStatusInvldParam]
/// \~english @par Detail
///        This API initializes thread attribute object for child thread with specified value.\n
///        \n
/// \~english @par Classification
///        Public
/// \~english @see
///        FrameworkunifiedCreateChildThreadWithAttribute
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedCreateChildThreadAttrSetSched(FrameworkunifiedChildThreadAttr *attr, EFrameworkunifiedSchedPolicy policy, SI_32 priority);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedStartChildThread
/// \~english @par Brief
///        Send initialize request to the child thread.
/// \~english @param [in] hApp
///        HANDLE   - Handle for Application of parent thread
/// \~english @param [in] hChildQ
///        HANDLE   - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
/// \~english @param [in] length
///        UI_32   - Length of send message data
/// \~english @param [in] data
///        PCVOID   - Pointer to message data
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
///        - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state is depend on application implements.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
///        - Thread name specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
///        - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
///        - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
///        - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
///        - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
///        - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
///        - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
///        - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
/// \~english @par Detail
///        This API sends initialize request to the child thread from parent thread.\n
///        Taking this request,
///        child thread runs callback function for initialize that specified when the thread create.
/// \~english @par
///        \n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        Open Close
/// \~english @see
///        FrameworkunifiedStopChildThread
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedStartChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedStopChildThread
/// \~english @par Brief
///        Send shutdown request to the child thread.
/// \~english @param [in] hApp
///        HANDLE   - Handle for Application of parent thread
/// \~english @param [in] hChildQ
///        HANDLE   - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
/// \~english @param [in] length
///        UI_32   - Length of send message data
/// \~english @param [in] data
///        PCVOID   - Pointer to message data
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
///        - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state is depend on application implements.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
///        - Thread name specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
///        - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
///        - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
///        - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
///        - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
///        - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
///        - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
///        - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
/// \~english @par Detail
///        This API sends shutdown request to the child thread.\n
///        Taking this request,
///        child thread runs  callback function for shutdown that specified when the thread create.\n
///        This API does not terminate child thread.
///        Use FrameworkunifiedDestroyChildThread to terminate child thread from parent thread.
/// \~english @par
///        \n
/// \~english @par Classification
///        Public
/// \~english @see
///        FrameworkunifiedStartChildThread FrameworkunifiedDestroyChildThread
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedStopChildThread(HANDLE hApp, HANDLE hChildQ, UI_32 length, PCVOID data);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedDestroyChildThread
/// \~english @par Brief
///        Terminate child thread.
/// \~english @param [in] hApp
///        HANDLE   - Handle for Application of parent thread
/// \~english @param [in] hChildQ
///        HANDLE   - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
/// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
/// \~english @retval eFrameworkunifiedStatusThreadSelfJoin Self thread specified
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
///        - Generation/Initialization of Dispatcher for the child thread
///          (FrameworkunifiedCreateChildThread, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state is depend on application implements.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldParam]
///        - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldParam]
///        - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldParam]
///        - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - Thread name specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
///        - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
///        - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
///        - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
///        - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
///        - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
///        - Message data size is invalid. [eFrameworkunifiedStatusInvldBufSize]
///        - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
///        - Child thread is invalid (thread exit or invalid) [eFrameworkunifiedStatusInvldHandle]
///        - Another thread is already waiting to join with this child thread. [eFrameworkunifiedStatusInvldParam]
///        - Already child thread is in termination process [eFrameworkunifiedStatusInvldParam]
///        - Thread specified in argument is self thread. [eFrameworkunifiedStatusThreadSelfJoin]
///        - Failed to close message queue specified in the argument (hChildQ). [eFrameworkunifiedStatusInvldHandle]
/// \~english @par Detail
///       This API sends terminate request to child thread , and waits to terminate child thread.\n
///       Taking this request, child thread  terminates itself.\n
///       After child thread terminates, parent thread destroys handle for communicate with child thread.
/// \~english @par Classification
///          Public
/// \~english @see FrameworkunifiedCreateChildThread FrameworkunifiedCreateChildThreadWithAttribute FrameworkunifiedCreateChildThreadWithPriority
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedDestroyChildThread(HANDLE hApp, HANDLE hChildQ);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedSendChild
/// \~english @par Brief
///        Send a message to the child thread.
/// \~english @param [in] hApp
///        HANDLE   - Handle for Application of parent thread
/// \~english @param [in] hChildQ
///        HANDLE   - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
/// \~english @param [in] iCmd
///        UI_32   - Command of message
/// \~english @param [in] length
///        UI_32   - Length of send message data
/// \~english @param [in] data
///        PCVOID   - Pointer to message data
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
///        - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildQ) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildQ) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
///        - Thread name specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
///        - Message queue name of child thread specified in the argument (hChildQ) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
///        - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
///        - Type of message queue to child thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
///        - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
///        - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
///        - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
///        - Any errors occur during the transmission of message to the child thread. [eFrameworkunifiedStatusFail]
/// \~english @par Detail
///        This API sends a message to the child thread from parent thread.\n
///        This API is available only from parent thread.
/// \~english @par
///        \n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        FrameworkunifiedSendParent
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedSendChild(HANDLE hApp, HANDLE hChildQ, UI_32 iCmd, UI_32 length, PCVOID data);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedSendParent
/// \~english @par Brief
///        Send a message to the parent thread.
/// \~english @param [in] hChildApp
///        HANDLE   - Handle for Application of child thread(get as argument of callback function)
/// \~english @param [in] iCmd
///        UI_32   - Command of message
/// \~english @param [in] length
///        UI_32   - Length of send message data
/// \~english @param [in] data
///        PCVOID   - Pointer to message data
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
/// \~english @retval eFrameworkunifiedStatusInvldBuf Invalid buffer
/// \~english @retval eFrameworkunifiedStatusInvldQName Illegal Message Queue name
/// \~english @retval eFrameworkunifiedStatusErrOther Other error has occurred(Cannot access shared memory, etc.)
/// \~english @retval eFrameworkunifiedStatusInvldHndlType Invalid type of handle
/// \~english @retval eFrameworkunifiedStatusMsgQFull Message queue is full
/// \~english @retval eFrameworkunifiedStatusErrNoEBADF Invalid File-Descriptor
/// \~english @retval eFrameworkunifiedStatusErrNoEINTR An interrupt is generated by the system call (signal)
/// \~english @retval eFrameworkunifiedStatusInvldBufSize Invalid buffer-size
/// \~english @retval eFrameworkunifiedStatusFail Some sort of error occurred
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
///        - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildApp) is not appropriate (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - Message queue for parent thread in HANDLE (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - Message queue for parent thread in HANDLE (hChildApp) is not appropriate
///          (which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - Data buffer specified in the argument (data) is NULL. [eFrameworkunifiedStatusInvldBuf]
///        - Thread name specified in the argument (hChildApp) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldQName]
///        - The name of message queue for parent thread specified in the argument (hChildApp) is not appropriate
///          (The name is NULL, more than 20byte). [eFrameworkunifiedStatusInvldHandle]
///        - Failed to access to shared memory for sending message. [eFrameworkunifiedStatusErrOther]
///        - Type of message queue to parent thread is not for sending. [eFrameworkunifiedStatusInvldHndlType]
///        - Message queue for sending is full. [eFrameworkunifiedStatusMsgQFull]
///        - File descriptor of sending message is invalid. [eFrameworkunifiedStatusErrNoEBADF]
///        - Interruption by the system call (signal) has occurred during message sending. [eFrameworkunifiedStatusErrNoEINTR]
///        - Any errors occur during the transmission of message to the parent thread. [eFrameworkunifiedStatusFail]
/// \~english @par Detail
///        This API sends a message to the parent thread from child thread.\n
///        This API is available only from child thread.
/// \~english @par
///        \n
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        FrameworkunifiedSendChild
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedSendParent(HANDLE hChildApp, UI_32 iCmd, UI_32 length, PCVOID data);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedJoinChild
/// \~english @par Brief
///        Wait for child thread terminates.
/// \~english @param [in] hChildApp
///        HANDLE   - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
/// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
/// \~english @retval eFrameworkunifiedStatusInvldParam Invalid parameter
/// \~english @retval eFrameworkunifiedStatusThreadSelfJoin Self thread specified
/// \~english @retval eFrameworkunifiedStatusFail thread exit or invalid
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
///        - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - Child thread is invalid (thread exit or invalid) [eFrameworkunifiedStatusFail]
///        - Another thread is already waiting to join with this child thread. [eFrameworkunifiedStatusInvldParam]
///        - Already child thread is in termination process [eFrameworkunifiedStatusInvldParam]
///        - Thread specified in argument is self thread. [eFrameworkunifiedStatusThreadSelfJoin]
/// \~english @par Detail
///        It waits for terminate of child thread it was created by FrameworkunifiedCreateChildThread
///        (or similar one) in the parent thread.\n
///        This API blocks the calling thread until child thread terminates.\n
///        This API does not terminate child thread.
///        Use FrameworkunifiedDestroyChildThread to terminate child thread from parent thread.
/// \~english @par Classification
///        Public
/// \~english @see
///        FrameworkunifiedCreateChildThread, FrameworkunifiedCreateChildThreadWithPriority, FrameworkunifiedDestroyChildThread
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedJoinChild(HANDLE hChildApp);

////////////////////////////////////////////////////////////////////////////////////////////
/// \ingroup FrameworkunifiedGetChildThreadPriority
/// \~english @par Brief
///        Get the child thread priority.
/// \~english @param [in] hChildApp
///        HANDLE   - Handle for communicate with child thread(returned by FrameworkunifiedCreateChildThread)
/// \~english @param [out] threadPrio
///        PSI_32   - Dispatcher file descriptor
/// \~english @retval eFrameworkunifiedStatusOK Success
/// \~english @retval eFrameworkunifiedStatusInvldHandle Invalid handle
/// \~english @retval eFrameworkunifiedStatusThreadNotExist Thread is not exist
/// \~english @retval eFrameworkunifiedStatusFault Error occured during function
/// \~english @par Prerequisite
///        - Generation/Initialization of Dispatcher for the Application
///          (FrameworkunifiedCreateDispatcherWithoutLoop, etc.) has been done.
///        - Generation/Initialization of Dispatcher for the child thread (FrameworkunifiedCreateChildThread, etc.) has been done.
/// \~english @par Change of internal state
///        - Change of internal state according to the API does not occur.
/// \~english @par Conditions of processing failure
///        - HANDLE specified in the argument (hChildApp) is NULL. [eFrameworkunifiedStatusInvldHandle]
///        - HANDLE specified in the argument (hChildApp) is not appropriate(which is invalid). [eFrameworkunifiedStatusInvldHandle]
///        - child thread priority in the argument (threadPrio) is NULL. [eFrameworkunifiedStatusInvldParam]
///        - Failed to get child thread priority (pthread_getschedparam). [eFrameworkunifiedStatusFault]
///        - If child threads are inalid or already terminated. [eFrameworkunifiedStatusThreadNotExist]
/// \~english @par Detail
///        This API set the child thread priority generated by FrameworkunifiedCreateChildThread to argument threadPrio.
///        Use to get child thread priority from parent thread.
/// \~english @par Classification
///        Public
/// \~english @par Type
///        No match
/// \~english @see
///        FrameworkunifiedCreateChildThread, FrameworkunifiedCreateChildThreadWithPriority
////////////////////////////////////////////////////////////////////////////////////////////
EFrameworkunifiedStatus FrameworkunifiedGetChildThreadPriority(HANDLE hChildApp, PSI_32 threadPrio);
#endif  // __NSFRAMEWORK_NFRAMEWORKCORE_MULTITHREADING__  NOLINT  (build/header_guard)
/** @}*/
/** @}*/
/** @}*/
/** @}*/
//@}