• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ PR_EnterMonitor函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C++中PR_EnterMonitor函数的典型用法代码示例。如果您正苦于以下问题:C++ PR_EnterMonitor函数的具体用法?C++ PR_EnterMonitor怎么用?C++ PR_EnterMonitor使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。



在下文中一共展示了PR_EnterMonitor函数的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。

示例1: ResourceChainFront

//
// Debug implementation of ReentrantMonitor
void
ReentrantMonitor::Enter()
{
  BlockingResourceBase* chainFront = ResourceChainFront();

  // the code below implements monitor reentrancy semantics

  if (this == chainFront) {
    // immediately re-entered the monitor: acceptable
    PR_EnterMonitor(mReentrantMonitor);
    ++mEntryCount;
    return;
  }

  CallStack callContext = CallStack();

  // this is sort of a hack around not recording the thread that
  // owns this monitor
  if (chainFront) {
    for (BlockingResourceBase* br = ResourceChainPrev(chainFront);
         br;
         br = ResourceChainPrev(br)) {
      if (br == this) {
        NS_WARNING(
          "Re-entering ReentrantMonitor after acquiring other resources.\n"
          "At calling context\n");
        GetAcquisitionContext().Print(stderr);

        // show the caller why this is potentially bad
        CheckAcquire(callContext);

        PR_EnterMonitor(mReentrantMonitor);
        ++mEntryCount;
        return;
      }
    }
  }

  CheckAcquire(callContext);
  PR_EnterMonitor(mReentrantMonitor);
  NS_ASSERTION(mEntryCount == 0, "ReentrantMonitor isn't free!");
  Acquire(callContext);       // protected by mReentrantMonitor
  mEntryCount = 1;
}
开发者ID:chenhequn,项目名称:gecko,代码行数:46,代码来源:BlockingResourceBase.cpp


示例2: WaitMonitorThread

static void WaitMonitorThread(void *arg)
{
    PRIntervalTime timeout = (PRIntervalTime) arg;
    PRIntervalTime elapsed;
#if defined(XP_UNIX) || defined(WIN32)
    PRInt32 timeout_msecs = PR_IntervalToMilliseconds(timeout);
    PRInt32 elapsed_msecs;
#endif
#if defined(XP_UNIX)
    struct timeval end_time_tv;
#endif
#if defined(WIN32) && !defined(WINCE)
    struct _timeb end_time_tb;
#endif
    PRMonitor *mon;

    mon = PR_NewMonitor();
    if (mon == NULL) {
        fprintf(stderr, "PR_NewMonitor failed\n");
        exit(1);
    }
    PR_EnterMonitor(mon);
    PR_Wait(mon, timeout);
    PR_ExitMonitor(mon);
    elapsed = (PRIntervalTime)(PR_IntervalNow() - start_time);
    if (elapsed + tolerance < timeout || elapsed > timeout + tolerance) {
        fprintf(stderr, "timeout wrong\n");
        exit(1);
    }
#if defined(XP_UNIX)
    gettimeofday(&end_time_tv, NULL);
    elapsed_msecs = 1000*(end_time_tv.tv_sec - start_time_tv.tv_sec)
            + (end_time_tv.tv_usec - start_time_tv.tv_usec)/1000;
#endif
#if defined(WIN32)
#if defined(WINCE)
    elapsed_msecs = GetTickCount() - start_time_tick;
#else
    _ftime(&end_time_tb);
    elapsed_msecs = 1000*(end_time_tb.time - start_time_tb.time)
            + (end_time_tb.millitm - start_time_tb.millitm);
#endif
#endif
#if defined(XP_UNIX) || defined(WIN32)
    if (elapsed_msecs + tolerance_msecs < timeout_msecs
            || elapsed_msecs > timeout_msecs + tolerance_msecs) {
        fprintf(stderr, "timeout wrong\n");
        exit(1);
    }
#endif
    PR_DestroyMonitor(mon);
    if (debug_mode) {
        fprintf(stderr, "wait monitor thread (scope %d) done\n",
                PR_GetThreadScope(PR_GetCurrentThread()));
    }
}
开发者ID:Akheon23,项目名称:chromecast-mirrored-source.external,代码行数:56,代码来源:y2ktmo.c


示例3: PR_EnterMonitor

NS_IMETHODIMP nsIMAPHostSessionList::GetOnlineDirForHost(const char *serverKey,
                                                         nsString &result)
{
  PR_EnterMonitor(gCachedHostInfoMonitor);
  nsIMAPHostInfo *host = FindHost(serverKey);
  if (host)
    CopyASCIItoUTF16(host->fOnlineDir, result);
  PR_ExitMonitor(gCachedHostInfoMonitor);
  return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK;
}
开发者ID:vanto,项目名称:comm-central,代码行数:10,代码来源:nsIMAPHostSessionList.cpp


示例4: TryEntry

static void PR_CALLBACK TryEntry(void *arg)
{
    PRMonitor *ml = (PRMonitor*)arg;
    if (debug_mode) PR_fprintf(std_err, "Reentrant thread created\n");
    PR_EnterMonitor(ml);
    PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
    if (debug_mode) PR_fprintf(std_err, "Reentrant thread acquired monitor\n");
    PR_ExitMonitor(ml);
    if (debug_mode) PR_fprintf(std_err, "Reentrant thread released monitor\n");
}  /* TryEntry */
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:10,代码来源:lock.c


示例5: PR_EnterMonitor

NS_IMETHODIMP nsIMAPHostSessionList::GetOnlineTrashFolderExistsForHost(const char *serverKey, PRBool &result)
{
  
  PR_EnterMonitor(gCachedHostInfoMonitor);
  nsIMAPHostInfo *host = FindHost(serverKey);
  if (host)
    result = host->fOnlineTrashFolderExists;
  PR_ExitMonitor(gCachedHostInfoMonitor);
  return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK;
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:10,代码来源:nsIMAPHostSessionList.cpp


示例6: gpsee_destroyMonitor

/**
 *  Destroy a monitor that was created by gpsee_createMonitor(). It is the caller's
 *  responsibility to insure that no other threads may want to use the monitor while
 *  this routine is running.
 *
 *  @param      grt             The GPSEE runtime which owns the monitor
 *  @param      monitor         The monitor to destroy
 */
void gpsee_destroyMonitor(gpsee_runtime_t *grt, gpsee_monitor_t monitor)
{
#ifdef JS_THREADSAFE
  if (monitor == nilMonitor)
    return;

  PR_EnterMonitor(grt->monitors.monitor);
  gpsee_ds_remove(grt->monitorList_unlocked, monitor);
  PR_ExitMonitor(grt->monitors.monitor);
  PR_DestroyMonitor(monitor);
#endif
}
开发者ID:wesgarland,项目名称:gpsee,代码行数:20,代码来源:gpsee_monitors.c


示例7: PR_GetCurrentThread

// create new event queue, append it to the current thread's chain of event queues.
// return it, addrefed.
NS_IMETHODIMP
nsEventQueueServiceImpl::PushThreadEventQueue(nsIEventQueue **aNewQueue)
{
  nsresult rv = NS_OK;
  PRThread* currentThread = PR_GetCurrentThread();
  PRBool native = PR_TRUE; // native by default as per old comment


  NS_ASSERTION(aNewQueue, "PushThreadEventQueue called with null param");

  /* Enter the lock that protects the EventQ hashtable... */
  PR_EnterMonitor(mEventQMonitor);

  nsIEventQueue* queue = mEventQTable.GetWeak(currentThread);
  
  NS_ASSERTION(queue, "pushed event queue on top of nothing");

  if (queue) { // find out what kind of queue our relatives are
    nsCOMPtr<nsIEventQueue> youngQueue;
    GetYoungestEventQueue(queue, getter_AddRefs(youngQueue));
    if (youngQueue) {
      youngQueue->IsQueueNative(&native);
    }
  }

  nsIEventQueue* newQueue = nsnull;
  MakeNewQueue(currentThread, native, &newQueue); // create new queue; addrefs

  if (!queue) {
    // shouldn't happen. as a fallback, we guess you wanted a native queue
    mEventQTable.Put(currentThread, newQueue);
  }

  // append to the event queue chain
  nsCOMPtr<nsPIEventQueueChain> ourChain(do_QueryInterface(queue)); // QI the queue in the hash table
  if (ourChain)
    ourChain->AppendQueue(newQueue); // append new queue to it

  *aNewQueue = newQueue;

#if defined(PR_LOGGING) && defined(DEBUG_danm)
  PLEventQueue *equeue;
  (*aNewQueue)->GetPLEventQueue(&equeue);
  PR_LOG(gEventQueueLog, PR_LOG_DEBUG,
         ("EventQueue: Service push queue [queue=%lx]",(long)equeue));
  ++gEventQueueLogCount;
#endif

  // Release the EventQ lock...
  PR_ExitMonitor(mEventQMonitor);
  return rv;
}
开发者ID:bringhurst,项目名称:vbox,代码行数:54,代码来源:nsEventQueueService.cpp


示例8: PR_EnterMonitor

void
nsDNSSyncRequest::OnLookupComplete(nsHostResolver *resolver,
                                   nsHostRecord   *hostRecord,
                                   nsresult        status)
{
    // store results, and wake up nsDNSService::Resolve to process results.
    PR_EnterMonitor(mMonitor);
    mDone = PR_TRUE;
    mStatus = status;
    mHostRecord = hostRecord;
    PR_Notify(mMonitor);
    PR_ExitMonitor(mMonitor);
}
开发者ID:rn10950,项目名称:RetroZilla,代码行数:13,代码来源:nsDNSService2.cpp


示例9: PKIX_PL_MonitorLock_Enter

PKIX_Error *
PKIX_PL_MonitorLock_Enter(
    PKIX_PL_MonitorLock *monitorLock,
    void *plContext)
{
    PKIX_ENTER_NO_LOGGER(MONITORLOCK, "PKIX_PL_MonitorLock_Enter");
    PKIX_NULLCHECK_ONE(monitorLock);

    PKIX_MONITORLOCK_DEBUG("\tCalling PR_EnterMonitor)\n");
    (void) PR_EnterMonitor(monitorLock->lock);

    PKIX_RETURN_NO_LOGGER(MONITORLOCK);
}
开发者ID:lofter2011,项目名称:Icefox,代码行数:13,代码来源:pkix_pl_monitorlock.c


示例10: NonContentiousMonitor

static PRIntervalTime NonContentiousMonitor(PRUint32 loops)
{
    PRMonitor *ml = NULL;
    ml = PR_NewMonitor();
    while (loops-- > 0)
    {
        PR_EnterMonitor(ml);
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(ml);
        PR_ExitMonitor(ml);
    }
    PR_DestroyMonitor(ml);
    return 0;
}  /* NonContentiousMonitor */
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:13,代码来源:lock.c


示例11: Level_0_Thread

static void Level_0_Thread(PRThreadScope scope1, PRThreadScope scope2)
{
    PRThread *thr;
    PRThread *me = PR_GetCurrentThread();
    int n;
    PRInt32 words;
    PRWord *registers;

    alive = 0;
    mon = PR_NewMonitor();

    alive = count;
    for (n=0; n<count; n++) {
        thr = PR_CreateThreadGCAble(PR_USER_THREAD,
            Level_1_Thread, 
            (void *)scope2, 
            PR_PRIORITY_NORMAL,
            scope1,
            PR_UNJOINABLE_THREAD,
            0);
        if (!thr) {
            printf("Could not create thread!\n");
            alive--;
        }
        printf("Level_0_Thread[0x%lx] created %15s thread 0x%lx\n",
            PR_GetCurrentThread(),
            (scope1 == PR_GLOBAL_THREAD) ?
            "PR_GLOBAL_THREAD" : "PR_LOCAL_THREAD",
            thr);

        PR_Sleep(0);
    }
    PR_SuspendAll();
    PR_EnumerateThreads(print_thread, NULL);
    registers = PR_GetGCRegisters(me, 1, (int *)&words);
    if (registers)
        printf("My Registers: R0 = 0x%x R1 = 0x%x R2 = 0x%x R3 = 0x%x\n",
            registers[0],registers[1],registers[2],registers[3]);
    printf("My Stack Pointer = 0x%lx\n", PR_GetSP(me));
    PR_ResumeAll();

    /* Wait for all threads to exit */
    PR_EnterMonitor(mon);
    while (alive) {
        PR_Wait(mon, PR_INTERVAL_NO_TIMEOUT);
    }

    PR_ExitMonitor(mon);
    PR_DestroyMonitor(mon);
}
开发者ID:Anachid,项目名称:mozilla-central,代码行数:50,代码来源:suspend.c


示例12: uidString

NS_IMETHODIMP nsIMAPHostSessionList::FindShellInCacheForHost(const char *serverKey, const char *mailboxName, const char *UID,
                                                             IMAP_ContentModifiedType modType, nsIMAPBodyShell **shell)
{
  nsCString uidString(UID);

  PR_EnterMonitor(gCachedHostInfoMonitor);
  nsIMAPHostInfo *host = FindHost(serverKey);
  if (host && host->fShellCache)
    NS_IF_ADDREF(*shell = host->fShellCache->FindShellForUID(uidString,
                                                             mailboxName,
                                                             modType));
  PR_ExitMonitor(gCachedHostInfoMonitor);
  return (host == NULL) ? NS_ERROR_ILLEGAL_VALUE : NS_OK;
}
开发者ID:vanto,项目名称:comm-central,代码行数:14,代码来源:nsIMAPHostSessionList.cpp


示例13: MonitorContender

static void PR_CALLBACK MonitorContender(void *arg)
{
    MonitorContentious_t *contention = (MonitorContentious_t*)arg;
    while (contention->loops-- > 0)
    {
        PR_EnterMonitor(contention->ml);
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);
        contention->contender+= 1;
        contention->overhead += contention->interval;
        PR_Sleep(contention->interval);
        PR_ASSERT_CURRENT_THREAD_IN_MONITOR(contention->ml);
        PR_ExitMonitor(contention->ml);
    }
}  /* MonitorContender */
开发者ID:Akin-Net,项目名称:mozilla-central,代码行数:14,代码来源:lock.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ PR_ExecuteProgram函数代码示例发布时间:2022-05-30
下一篇:
C++ PR_DestroyLock函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap