Changeset 35 in libcf for trunk/include/cf_thread.h


Ignore:
Timestamp:
02/05/13 18:18:37 (11 years ago)
Author:
cheese
Message:

#1 separate example code and doxygen comment and fix logging push logic by vfire

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/include/cf_thread.h

    r34 r35  
    66 * @remark 멀티스레드 및 뮤텍스 지원
    77 *
    8  * @section 샘플코드
    9  * @code
    10 
    11 #include "cf_thread.h"
    12 
    13 CF_Mutex globalMutex;
    14 
    15 CF_THREAD_RETURN CF_THREAD_CALL worker (void * arg) {
    16     if (CF_Mutex_Create (&globalMutex) < 0) {
    17         // error
    18     }
    19 
    20     if (CF_Mutex_Lock (&globalMutex) < 0) { // for critical section
    21         // error
    22     }
    23 
    24     // critical section
    25 
    26     if (CF_Mutex_Unlock (&globalMutex) < 0) { // for critical section
    27         // error
    28     }
    29 
    30     if (CF_Mutex_Destory (&globalMutex) < 0) {
    31         // error
    32     }
    33 }
    34 
    35 int main (void) {
    36     CF_Thread tid;
    37     if (CF_Thread_Create (&tid, worker, NULL) < 0) {
    38         // error
    39     }
    40 
    41     if (CF_Thread_Join (&tid) < 0) { // block
    42         // error
    43     }
    44 
    45     if (CF_Thread_Release (&tid) < 0) {
    46         // error
    47     }
    48     return 0;
    49 }
    50 
    51  * @endcode
     8 * @example thread.c
    529 */
    5310#ifndef __CF_THREAD_H__
     
    8340#endif
    8441
    85 /**
    86  * 스레드를 생성
    87  *
    88  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    89  *
    90  * @param threadID  스레드 아이디 주소
    91  * @param callback  스레드 워커 함수 이름
    92  * @param arg       스레드 함수로 전달할 인자
    93  */
    9442CF_EXPORT int
    9543CF_Thread_Create    (CF_Thread          * threadID,
     
    9745                     void               * arg);
    9846
    99 /**
    100  * 스레드 아이디를 해제
    101  *
    102  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    103  *
    104  * @param threadID 스레드 아이디 주소
    105  *
    106  * @remark 스레드 아이디를 해제하는 것이며 워커 스레드가 종료되지 않음
    107  */
    10847CF_EXPORT int
    10948CF_Thread_Release   (CF_Thread * threadID);
    11049
    111 /**
    112  * 스레드가 종료될 때 까지 대기
    113  *
    114  * @return CF_OK 반환
    115  *
    116  * @param threadID 스레드 아이디 주소
    117  */
    11850CF_EXPORT int
    11951CF_Thread_Join      (CF_Thread * threadID);
    12052
    121 /**
    122  * 뮤텍스 생성
    123  *
    124  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    125  *
    126  * @param mutex 뮤텍스 아이디 주소
    127  *
    128  * @see CF_Thread_Create
    129  */
    13053CF_EXPORT int
    13154CF_Mutex_Create     (CF_Mutex * mutex);
    13255
    133 /**
    134  * 뮤텍스 해제
    135  *
    136  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    137  *
    138  * @param mutex 뮤텍스 아이디 주소
    139  */
    14056CF_EXPORT int
    14157CF_Mutex_Destory    (CF_Mutex * mutex);
    14258
    143 /**
    144  * 뮤텍스 잠금
    145  *
    146  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    147  *
    148  * @param mutex 뮤텍스 아이디 주소
    149  */
    15059CF_EXPORT int
    15160CF_Mutex_Lock       (CF_Mutex * mutex);
    15261
    153 /**
    154  * 뮤텍스 잠금 해제
    155  *
    156  * @return 성공 시, CF_OK; 실패 시, 오류 코드
    157  *
    158  * @param mutex 뮤텍스 아이디 주소
    159  */
    16062CF_EXPORT int
    16163CF_Mutex_Unlock     (CF_Mutex * mutex);
Note: See TracChangeset for help on using the changeset viewer.