nspr线程相关

NSPR 线程

    PRThread *thr;

    thr = PR_CreateThread(PR_USER_THREAD,
                          hello_thread,
                          NULL,
                          PR_PRIORITY_NORMAL,
                          PR_LOCAL_THREAD,
                          PR_JOINABLE_THREAD,
                          0);


#include <prthread.h>

typedef enum PRThreadType {
   PR_USER_THREAD,
   PR_SYSTEM_THREAD
} PRThreadType;

Enumerators

PR_USER_THREAD
    PR_Cleanup blocks until the last thread of type PR_USER_THREAD terminates.
    PR_Cleanup 会阻塞等待最后一个PR_USER_THREAD线程才往下执行
PR_SYSTEM_THREAD
    NSPR ignores threads of type PR_SYSTEM_THREAD when determining when a call to PR_Cleanup should return.


===========================================================================================================

#include <prthread.h>

typedef enum PRThreadScope {
   PR_LOCAL_THREAD,
   PR_GLOBAL_THREAD
   PR_GLOBAL_BOUND_THREAD
} PRThreadScope;

PR_LOCAL_THREAD  默认用这个

===========================================================================================================
typedef enum PRThreadState {
   PR_JOINABLE_THREAD,
   PR_UNJOINABLE_THREAD
} PRThreadState;

PR_UNJOINABLE_THREAD 类型分离式,主线程退出,不等待子线程,子线程自己退出释放资源

PR_JOINABLE_THREAD    类型,主线程需要调用PR_JoinThread(thr); 等待线程退出,才会释放资源



===========================================================================================================
优先级默认用:PR_PRIORITY_NORMAL  


#include <prthread.h>

typedef enum PRThreadPriority
{   
   PR_PRIORITY_FIRST   = 0,
   PR_PRIORITY_LOW     = 0,
   PR_PRIORITY_NORMAL  = 1,
   PR_PRIORITY_HIGH    = 2,
   PR_PRIORITY_URGENT  = 3,
   PR_PRIORITY_LAST    = 3
} PRThreadPriority;

Enumerators

PR_PRIORITY_FIRST
    Placeholder.
PR_PRIORITY_LOW
    The lowest possible priority. This priority is appropriate for threads that are expected to perform intensive computation.
PR_PRIORITY_NORMAL
    The most commonly expected priority.
PR_PRIORITY_HIGH
    Slightly higher priority than PR_PRIORITY_NORMAL. This priority is for threads performing work of high urgency but short duration.
PR_PRIORITY_URGENT
    Highest priority. Only one thread at a time typically has this priority.
PR_PRIORITY_LAST
    Placeholder
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值