当前位置: 首页>>代码示例>>C++>>正文


C++ PR_CreateThread函数代码示例

本文整理汇总了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;
}
开发者ID:Jar-win,项目名称:Waterfox,代码行数:11,代码来源:ClosingService.cpp

示例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;
}
开发者ID:binoc-software,项目名称:mozilla-cvs,代码行数:52,代码来源:sleep.c

示例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;
}
开发者ID:nmaier,项目名称:downthemall-asyncwrite,代码行数:13,代码来源:pr.c

示例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 */
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.external,代码行数:39,代码来源:xnotify.c

示例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");
}
开发者ID:leto,项目名称:389-ds,代码行数:19,代码来源:eventq.c

示例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);
}
开发者ID:Noctem,项目名称:gecko-dev,代码行数:13,代码来源:GraphRunner.cpp

示例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
}
开发者ID:Akesure,项目名称:jxcore,代码行数:54,代码来源:prtpool.c

示例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");
}
开发者ID:jpfreire,项目名称:mozilla-central,代码行数:14,代码来源:BackgroundHangMonitor.cpp

示例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;
}
开发者ID:LittleForker,项目名称:mozilla-central,代码行数:14,代码来源:nsAppStartup.cpp

示例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;
}
开发者ID:1981khj,项目名称:rainbow,代码行数:14,代码来源:VideoSourceCanvas.cpp

示例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;
}
开发者ID:diocles,项目名称:gnash,代码行数:14,代码来源:plugin.cpp

示例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);
}
开发者ID:diversys,项目名称:bezilla,代码行数:53,代码来源:nsToolkit.cpp

示例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;
}
开发者ID:excitedhoney,项目名称:firefox,代码行数:16,代码来源:TimeStamp_posix.cpp

示例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++;
    }
}
开发者ID:AbrahamJewowich,项目名称:FreeSWITCH,代码行数:16,代码来源:sproc_ch.c

示例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);
}
开发者ID:MuniyappanV,项目名称:jdk-source-code,代码行数:16,代码来源:CNSAdapter_NSPR.cpp


注:本文中的PR_CreateThread函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。