本文整理汇总了C++中PR_CreateThread函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_CreateThread函数的具体用法?C++ PR_CreateThread怎么用?C++ PR_CreateThread使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PR_CreateThread函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: PR_CreateThread
nsresult
ClosingService::StartInternal()
{
mThread = PR_CreateThread(PR_USER_THREAD, ThreadFunc, this,
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD,
PR_JOINABLE_THREAD, 32 * 1024);
if (!mThread) {
return NS_ERROR_FAILURE;
}
return NS_OK;
}
示例2: main
PRIntn main ()
{
PRUint32 elapsed;
PRThread *thread;
struct timeval timein, timeout;
PRInt32 onePercent = 3000000UL / 100UL;
fprintf (stderr, "First sleep will sleep 3 seconds.\n");
fprintf (stderr, " sleep 1 begin\n");
(void)GTOD(&timein);
sleep (3);
(void)GTOD(&timeout);
fprintf (stderr, " sleep 1 end\n");
elapsed = 1000000UL * (timeout.tv_sec - timein.tv_sec);
elapsed += (timeout.tv_usec - timein.tv_usec);
fprintf(stderr, "elapsed %u usecs\n", elapsed);
if (labs(elapsed - 3000000UL) > onePercent) rv = 1;
PR_Init (PR_USER_THREAD, PR_PRIORITY_NORMAL, 100);
PR_STDIO_INIT();
fprintf (stderr, "Second sleep should do the same (does it?).\n");
fprintf (stderr, " sleep 2 begin\n");
(void)GTOD(&timein);
sleep (3);
(void)GTOD(&timeout);
fprintf (stderr, " sleep 2 end\n");
elapsed = 1000000UL * (timeout.tv_sec - timein.tv_sec);
elapsed += (timeout.tv_usec - timein.tv_usec);
fprintf(stderr, "elapsed %u usecs\n", elapsed);
if (labs(elapsed - 3000000UL) > onePercent) rv = 1;
fprintf (stderr, "What happens to other threads?\n");
fprintf (stderr, "You should see dots every quarter second.\n");
fprintf (stderr, "If you don't, you're probably running on classic NSPR.\n");
thread = PR_CreateThread(
PR_USER_THREAD, Other, NULL, PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
fprintf (stderr, " sleep 2 begin\n");
(void)GTOD(&timein);
sleep (3);
(void)GTOD(&timeout);
fprintf (stderr, " sleep 2 end\n");
PR_Interrupt(thread);
PR_JoinThread(thread);
elapsed = 1000000UL * (timeout.tv_sec - timein.tv_sec);
elapsed += (timeout.tv_usec - timein.tv_usec);
fprintf(stderr, "elapsed %u usecs\n", elapsed);
if (labs(elapsed - 3000000UL) > onePercent) rv = 1;
fprintf(stderr, "%s\n", (0 == rv) ? "PASSED" : "FAILED");
return rv;
}
示例3: thread_create
thread_t thread_create(thread_proc_t start, void *param) {
thread_t *rv;
return (thread_t)PR_CreateThread(
PR_USER_THREAD,
start,
param,
PR_PRIORITY_LOW,
PR_GLOBAL_THREAD,
PR_JOINABLE_THREAD,
0
);
return rv;
}
示例4: T1CMon
static void T1CMon(void)
{
PRStatus rv;
PRThread *t2, *t3;
PR_fprintf(err, "\n**********************************\n");
PR_fprintf(err, " CACHED MONITORS\n");
PR_fprintf(err, "**********************************\n");
base = PR_IntervalNow();
PR_CEnterMonitor(&sharedCM.o1);
LogNow("T1 waiting 3 seconds on o1", PR_SUCCESS);
rv = PR_CWait(&sharedCM.o1, PR_SecondsToInterval(3));
if (PR_SUCCESS == rv) LogNow("T1 resuming on o1", rv);
else LogNow("T1 wait on o1 failed", rv);
PR_CExitMonitor(&sharedCM.o1);
LogNow("T1 creating T2", PR_SUCCESS);
t2 = PR_CreateThread(
PR_USER_THREAD, T2CMon, &sharedCM, PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
LogNow("T1 creating T3", PR_SUCCESS);
t3 = PR_CreateThread(
PR_USER_THREAD, T3CMon, &sharedCM, PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD, PR_JOINABLE_THREAD, 0);
PR_CEnterMonitor(&sharedCM.o2);
LogNow("T1 waiting forever on o2", PR_SUCCESS);
rv = PR_CWait(&sharedCM.o2, PR_INTERVAL_NO_TIMEOUT);
if (PR_SUCCESS == rv) LogNow("T1 resuming on o2", rv);
else LogNow("T1 wait on o2 failed", rv);
PR_CExitMonitor(&sharedCM.o2);
(void)PR_JoinThread(t2);
(void)PR_JoinThread(t3);
} /* T1CMon */
示例5: eq_start
/*
* eq_start: start the event queue system.
*
* This should be called exactly once. It will start a
* thread which wakes up periodically and schedules events.
*/
void
eq_start()
{
PR_ASSERT(eq_initialized);
eq_running = 1;
if ((eq_loop_tid = PR_CreateThread(PR_USER_THREAD, (VFP)eq_loop,
NULL, PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD,
SLAPD_DEFAULT_THREAD_STACKSIZE)) == NULL) {
slapi_log_error(SLAPI_LOG_FATAL, NULL, "eq_init PR_CreateThread failed\n");
exit(1);
}
slapi_log_error(SLAPI_LOG_HOUSE, NULL, "event queue services have started\n");
}
示例6: mMonitor
GraphRunner::GraphRunner(MediaStreamGraphImpl* aGraph)
: mMonitor("GraphRunner::mMonitor"),
mGraph(aGraph),
mStateEnd(0),
mStillProcessing(true),
mThreadState(ThreadState::Wait),
// Note that mThread needs to be initialized last, as it may pre-empt the
// thread running this ctor and enter Run() with uninitialized members.
mThread(PR_CreateThread(PR_SYSTEM_THREAD, &Start, this,
PR_PRIORITY_URGENT, PR_GLOBAL_THREAD,
PR_JOINABLE_THREAD, 0)) {
MOZ_COUNT_CTOR(GraphRunner);
}
示例7: add_to_jobq
/*
* add a job to the work queue
*/
static void
add_to_jobq(PRThreadPool *tp, PRJob *jobp)
{
/*
* add to jobq
*/
#ifdef OPT_WINNT
PR_Lock(tp->jobq.lock);
tp->jobq.cnt++;
PR_Unlock(tp->jobq.lock);
/*
* notify worker thread(s)
*/
PostQueuedCompletionStatus(tp->jobq.nt_completion_port, 0,
FALSE, &jobp->nt_notifier.overlapped);
#else
PR_Lock(tp->jobq.lock);
PR_APPEND_LINK(&jobp->links,&tp->jobq.list);
tp->jobq.cnt++;
if ((tp->idle_threads < tp->jobq.cnt) &&
(tp->current_threads < tp->max_threads)) {
wthread *wthrp;
/*
* increment thread count and unlock the jobq lock
*/
tp->current_threads++;
PR_Unlock(tp->jobq.lock);
/* create new worker thread */
wthrp = PR_NEWZAP(wthread);
if (wthrp) {
wthrp->thread = PR_CreateThread(PR_USER_THREAD, wstart,
tp, PR_PRIORITY_NORMAL,
PR_GLOBAL_THREAD,PR_JOINABLE_THREAD,tp->stacksize);
if (NULL == wthrp->thread) {
PR_DELETE(wthrp); /* this sets wthrp to NULL */
}
}
PR_Lock(tp->jobq.lock);
if (NULL == wthrp) {
tp->current_threads--;
} else {
PR_APPEND_LINK(&wthrp->links, &tp->jobq.wthreads);
}
}
/*
* wakeup a worker thread
*/
PR_NotifyCondVar(tp->jobq.cv);
PR_Unlock(tp->jobq.lock);
#endif
}
示例8: mShutdown
BackgroundHangManager::BackgroundHangManager()
: mShutdown(false)
, mLock("BackgroundHangManager")
, mIntervalNow(0)
{
// Lock so we don't race against the new monitor thread
MonitorAutoLock autoLock(mLock);
mHangMonitorThread = PR_CreateThread(
PR_USER_THREAD, MonitorThread, this,
PR_PRIORITY_LOW, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
MOZ_ASSERT(mHangMonitorThread,
"Failed to create monitor thread");
}
示例9: CalculateProcessCreationTimestamp
static PRTime
CalculateProcessCreationTimestamp()
{
PRThread *thread = PR_CreateThread(PR_USER_THREAD,
ThreadedCalculateProcessCreationTimestamp,
NULL,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
PR_JoinThread(thread);
return gProcessCreationTimestamp;
}
示例10: PR_CreateThread
nsresult
VideoSourceCanvas::Start(nsIDOMCanvasRenderingContext2D *ctx)
{
if (!g2g)
return NS_ERROR_FAILURE;
vCanvas = ctx;
running = PR_TRUE;
sampler = PR_CreateThread(
PR_SYSTEM_THREAD, VideoSourceCanvas::Grabber, this,
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0
);
return NS_OK;
}
示例11: DBG
NPError
nsPluginInstance::DestroyStream(NPStream *stream, NPError reason)
{
DBG("nsPluginInstance::DestroyStream\n");
DBG("stream->url: %s\n", stream->url);
// N.B. We can only support one Gnash VM/thread right now.
if (!_thread) {
_thread = PR_CreateThread(PR_USER_THREAD, playerThread, this,
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_JOINABLE_THREAD, 0);
}
return NPERR_NO_ERROR;
}
示例12: PR_EnterMonitor
//-------------------------------------------------------------------------
//
// Create a new thread and run the message pump in there
//
//-------------------------------------------------------------------------
void nsToolkit::CreateUIThread()
{
PRMonitor *monitor = ::PR_NewMonitor();
PR_EnterMonitor(monitor);
ThreadInitInfo *ti = new ThreadInitInfo();
if (ti)
{
ti->monitor = monitor;
ti->toolkit = this;
// create a gui thread
mGuiThread = PR_CreateThread(PR_SYSTEM_THREAD,
RunPump,
(void*)ti,
PR_PRIORITY_HIGH,
PR_LOCAL_THREAD,
PR_UNJOINABLE_THREAD,
0);
// wait for the gui thread to start
while(gThreadState == PR_FALSE)
{
PR_Wait(monitor, PR_INTERVAL_NO_TIMEOUT);
}
}
image_info iinfo;
int32 cookie = 0;
char *leaf = NULL;
do {
if (get_next_image_info(0, &cookie, &iinfo) == B_OK &&
strlen(iinfo.name) > 0 &&
(leaf = strrchr(iinfo.name, '/')) != NULL)
{
leaf++;
mGUIThreadID = find_thread(leaf);
}
else
{
mGUIThreadID = find_thread(0);
}
} while(iinfo.type != B_APP_IMAGE);
// at this point the thread is running
PR_ExitMonitor(monitor);
PR_DestroyMonitor(monitor);
}
示例13: PR_CreateThread
uint64_t
TimeStamp::ComputeProcessUptime()
{
uint64_t uptime = 0;
PRThread *thread = PR_CreateThread(PR_USER_THREAD,
ComputeProcessUptimeThread,
&uptime,
PR_PRIORITY_NORMAL,
PR_LOCAL_THREAD,
PR_JOINABLE_THREAD,
0);
PR_JoinThread(thread);
return uptime / kNsPerUs;
}
示例14: NeverStops
void NeverStops(void *unused)
{
int i = 0;
printf("The child sproc has pid %d.\n", getpid());
printf("The child sproc won't stop on its own.\n");
fflush(stdout);
/* create the grandchild sproc */
PR_CreateThread(PR_USER_THREAD, SegFault, NULL,
PR_PRIORITY_NORMAL, PR_GLOBAL_THREAD, PR_UNJOINABLE_THREAD, 0);
while (1) {
i++;
}
}
示例15: JD_METHOD_
JD_METHOD_(void*) CNSAdapter_NSPR::JD_CreateThread(JDThreadType type,
void (*start)(void* arg),
void* arg,
JDThreadPriority priority,
JDThreadScope scope,
JDThreadState state,
JDUint32 stackSize)
{
return PR_CreateThread((PRThreadType)type,
start,
arg,
(PRThreadPriority)priority,
(PRThreadScope)scope,
(PRThreadState)state,
(PRUint32)stackSize);
}