當前位置: 首頁>>代碼示例>>C++>>正文


C++ ACQUIRE_LOCK函數代碼示例

本文整理匯總了C++中ACQUIRE_LOCK函數的典型用法代碼示例。如果您正苦於以下問題:C++ ACQUIRE_LOCK函數的具體用法?C++ ACQUIRE_LOCK怎麽用?C++ ACQUIRE_LOCK使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了ACQUIRE_LOCK函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: traceCapsetEvent_

void traceCapsetEvent_ (EventTypeNum tag,
                        CapsetID capset,
                        StgWord info)
{
#ifdef DEBUG
    if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
        ACQUIRE_LOCK(&trace_utx);

        tracePreface();
        switch (tag) {
        case EVENT_CAPSET_CREATE:   // (capset, capset_type)
            debugBelch("created capset %lu of type %d\n", (lnat)capset, (int)info);
            break;
        case EVENT_CAPSET_DELETE:   // (capset)
            debugBelch("deleted capset %lu\n", (lnat)capset);
            break;
        case EVENT_CAPSET_ASSIGN_CAP:  // (capset, capno)
            debugBelch("assigned cap %lu to capset %lu\n",
                       (lnat)info, (lnat)capset);
            break;
        case EVENT_CAPSET_REMOVE_CAP:  // (capset, capno)
            debugBelch("removed cap %lu from capset %lu\n",
                       (lnat)info, (lnat)capset);
            break;
        }
        RELEASE_LOCK(&trace_utx);
    } else
#endif
    {
        if (eventlog_enabled) {
            postCapsetEvent(tag, capset, info);
        }
    }
}
開發者ID:NathanHowell,項目名稱:ghc,代碼行數:34,代碼來源:Trace.c

示例2: traceCapEvent_

void traceCapEvent_ (Capability   *cap,
                     EventTypeNum  tag)
{
#ifdef DEBUG
    if (RtsFlags.TraceFlags.tracing == TRACE_STDERR) {
        ACQUIRE_LOCK(&trace_utx);

        tracePreface();
        switch (tag) {
        case EVENT_CAP_CREATE:   // (cap)
            debugBelch("cap %d: initialised\n", cap->no);
            break;
        case EVENT_CAP_DELETE:   // (cap)
            debugBelch("cap %d: shutting down\n", cap->no);
            break;
        case EVENT_CAP_ENABLE:   // (cap)
            debugBelch("cap %d: enabling capability\n", cap->no);
            break;
        case EVENT_CAP_DISABLE:  // (cap)
            debugBelch("cap %d: disabling capability\n", cap->no);
            break;
        }
        RELEASE_LOCK(&trace_utx);
    } else
#endif
    {
        if (eventlog_enabled) {
            postCapEvent(tag, (EventCapNo)cap->no);
        }
    }
}
開發者ID:lukemaurer,項目名稱:ghc,代碼行數:31,代碼來源:Trace.c

示例3: traceGcEvent_stderr

static void traceGcEvent_stderr (Capability *cap, EventTypeNum tag)
{
    ACQUIRE_LOCK(&trace_utx);

    tracePreface();
    switch (tag) {
      case EVENT_REQUEST_SEQ_GC:  // (cap)
          debugBelch("cap %d: requesting sequential GC\n", cap->no);
          break;
      case EVENT_REQUEST_PAR_GC:  // (cap)
          debugBelch("cap %d: requesting parallel GC\n", cap->no);
          break;
      case EVENT_GC_START:        // (cap)
          debugBelch("cap %d: starting GC\n", cap->no);
          break;
      case EVENT_GC_END:          // (cap)
          debugBelch("cap %d: finished GC\n", cap->no);
          break;
      case EVENT_GC_IDLE:         // (cap)
          debugBelch("cap %d: GC idle\n", cap->no);
          break;
      case EVENT_GC_WORK:         // (cap)
          debugBelch("cap %d: GC working\n", cap->no);
          break;
      case EVENT_GC_DONE:         // (cap)
          debugBelch("cap %d: GC done\n", cap->no);
          break;
      default:
          barf("traceGcEvent: unknown event tag %d", tag);
          break;
    }

    RELEASE_LOCK(&trace_utx);
}
開發者ID:NathanHowell,項目名稱:ghc,代碼行數:34,代碼來源:Trace.c

示例4: HvlLock

VOID
HvlLock(
    _In_  PHVL       pHvl
    )
{
    ACQUIRE_LOCK(pHvl, FALSE);                                               
}
開發者ID:340211173,項目名稱:Driver,代碼行數:7,代碼來源:hvl_main.c

示例5: sendMessage

void sendMessage(Capability *from_cap, Capability *to_cap, Message *msg)
{
    ACQUIRE_LOCK(&to_cap->lock);

#ifdef DEBUG    
    {
        const StgInfoTable *i = msg->header.info;
        if (i != &stg_MSG_THROWTO_info &&
            i != &stg_MSG_BLACKHOLE_info &&
            i != &stg_MSG_TRY_WAKEUP_info &&
            i != &stg_IND_info && // can happen if a MSG_BLACKHOLE is revoked
            i != &stg_WHITEHOLE_info) {
            barf("sendMessage: %p", i);
        }
    }
#endif

    msg->link = to_cap->inbox;
    to_cap->inbox = msg;

    recordClosureMutated(from_cap,(StgClosure*)msg);

    if (to_cap->running_task == NULL) {
	to_cap->running_task = myTask(); 
            // precond for releaseCapability_()
        releaseCapability_(to_cap,rtsFalse);
    } else {
        interruptCapability(to_cap);
    }

    RELEASE_LOCK(&to_cap->lock);
}
開發者ID:Eufavn,項目名稱:ghc,代碼行數:32,代碼來源:Messages.c

示例6: freeTaskManager

nat
freeTaskManager (void)
{
    Task *task, *next;
    nat tasksRunning = 0;

    ACQUIRE_LOCK(&all_tasks_mutex);

    for (task = all_tasks; task != NULL; task = next) {
        next = task->all_next;
        if (task->stopped) {
            freeTask(task);
        } else {
            tasksRunning++;
        }
    }

    debugTrace(DEBUG_sched, "freeing task manager, %d tasks still running",
               tasksRunning);

    all_tasks = NULL;

    RELEASE_LOCK(&all_tasks_mutex);

#if defined(THREADED_RTS)
    closeMutex(&all_tasks_mutex); 
#if !defined(MYTASK_USE_TLV)
    freeThreadLocalKey(&currentTaskKey);
#endif
#endif

    tasksInitialized = 0;

    return tasksRunning;
}
開發者ID:A1kmm,項目名稱:ghc,代碼行數:35,代碼來源:Task.c

示例7: stopTicker

/* There may be at most one additional tick fired after a call to this */
void
stopTicker(void)
{
    ACQUIRE_LOCK(&mutex);
    stopped = 1;
    RELEASE_LOCK(&mutex);
}
開發者ID:AaronFriel,項目名稱:ghc,代碼行數:8,代碼來源:Pthread.c

示例8: workerTaskStop

void
workerTaskStop (Task *task)
{
    DEBUG_ONLY( OSThreadId id );
    DEBUG_ONLY( id = osThreadId() );
    ASSERT(task->id == id);
    ASSERT(myTask() == task);

    ACQUIRE_LOCK(&all_tasks_mutex);

    if (task->all_prev) {
        task->all_prev->all_next = task->all_next;
    } else {
        all_tasks = task->all_next;
    }
    if (task->all_next) {
        task->all_next->all_prev = task->all_prev;
    }

    currentWorkerCount--;

    RELEASE_LOCK(&all_tasks_mutex);

    freeTask(task);
}
開發者ID:Eufavn,項目名稱:ghc,代碼行數:25,代碼來源:Task.c

示例9: readIOManagerEvent

HsWord32
readIOManagerEvent (void)
{
    // This function must exist even in non-THREADED_RTS,
    // see getIOManagerEvent() above.
#if defined(THREADED_RTS)
    HsWord32 res;

    ACQUIRE_LOCK(&event_buf_mutex);

    if (io_manager_event != INVALID_HANDLE_VALUE) {
        if (next_event == 0) {
            res = 0; // no event to return
        } else {
            res = (HsWord32)(event_buf[--next_event]);
            if (next_event == 0) {
                if (!ResetEvent(io_manager_event)) {
                    sysErrorBelch("readIOManagerEvent");
                    stg_exit(EXIT_FAILURE);
                }
            }
        }
    } else {
        res = 0;
    }

    RELEASE_LOCK(&event_buf_mutex);

    // debugBelch("readIOManagerEvent: %d\n", res);
    return res;
#else
    return 0;
#endif
}
開發者ID:alexbiehl,項目名稱:ghc,代碼行數:34,代碼來源:ThrIOManager.c

示例10: getIOManagerEvent

HANDLE
getIOManagerEvent (void)
{
    // This function has to exist even in the non-THREADED_RTS,
    // because code in GHC.Conc refers to it.  It won't ever be called
    // unless we're in the threaded RTS, however.
#ifdef THREADED_RTS
    HANDLE hRes;

    ACQUIRE_LOCK(&event_buf_mutex);

    if (io_manager_event == INVALID_HANDLE_VALUE) {
        hRes = CreateEvent ( NULL, // no security attrs
                             true, // manual reset
                             false, // initial state,
                             NULL ); // event name: NULL for private events
        if (hRes == NULL) {
            sysErrorBelch("getIOManagerEvent");
            stg_exit(EXIT_FAILURE);
        }
        io_manager_event = hRes;
    } else {
        hRes = io_manager_event;
    }

    RELEASE_LOCK(&event_buf_mutex);
    return hRes;
#else
    return NULL;
#endif
}
開發者ID:alexbiehl,項目名稱:ghc,代碼行數:31,代碼來源:ThrIOManager.c

示例11: startSignalHandlers

/*
 * Function: startSignalHandlers()
 *
 * Run the handlers associated with the stacked up console events. Console
 * event delivery is blocked for the duration of this call.
 */
void startSignalHandlers(Capability *cap)
{
    StgStablePtr handler;

    if (console_handler < 0) {
        return;
    }

    blockUserSignals();
    ACQUIRE_LOCK(&sched_mutex);

    handler = deRefStablePtr((StgStablePtr)console_handler);
    while (stg_pending_events > 0) {
        stg_pending_events--;
        scheduleThread(cap,
            createIOThread(cap,
                RtsFlags.GcFlags.initialStkSize,
                rts_apply(cap,
                    (StgClosure *)handler,
                    rts_mkInt(cap,
                        stg_pending_buf[stg_pending_events]))));
    }

    RELEASE_LOCK(&sched_mutex);
    unblockUserSignals();
}
開發者ID:alexbiehl,項目名稱:ghc,代碼行數:32,代碼來源:ConsoleHandler.c

示例12: Parse

NET_API_STATUS
Parse(
    IN DWORD argc,
    IN LPTSTR argv[]
    )
/*++

Routine Description :

    Wrapper function of the real worker Parse2 function.

Arguments :
    argc : argument count
    argv : argument string array pointer.

Return Value :
    return  NO_ERROR if successfully parse parameter
            ERROR_INVALID_PARAMETER, otherwise

--*/
{
    NET_API_STATUS  ApiStatus;
    LPNET_CONFIG_HANDLE ConfigHandle;

    // Get read-write lock for config data.  (The lock is for the in-memory
    // version of the data, which we're going to set.)
    ACQUIRE_LOCK( ReplGlobalConfigLock );

    // Open the config file (nt.cfg)
    ApiStatus = NetpOpenConfigData(
            & ConfigHandle,
            NULL,                 // local machine
            SECT_NT_REPLICATOR,   // section name
            TRUE);                // read-only


    if (ApiStatus != NO_ERROR) {
        NetpKdPrint(( "[REPL] Parse() can't open config section.\n" ));
        ReplFinish(
            SERVICE_UIC_CODE(
                SERVICE_UIC_SYSTEM,
                ApiStatus),
            NULL);

        RELEASE_LOCK( ReplGlobalConfigLock );
        return( ApiStatus );
    }


    ApiStatus = Parse2(argc, argv, ConfigHandle);

    // close config file ..

    (void) NetpCloseConfigData( ConfigHandle );

    RELEASE_LOCK( ReplGlobalConfigLock );

    return( ApiStatus );
}
開發者ID:mingpen,項目名稱:OpenNT,代碼行數:59,代碼來源:parse.c

示例13: startTicker

void
startTicker(void)
{
    ACQUIRE_LOCK(&mutex);
    stopped = 0;
    signalCondition(&start_cond);
    RELEASE_LOCK(&mutex);
}
開發者ID:AaronFriel,項目名稱:ghc,代碼行數:8,代碼來源:Pthread.c

示例14: defined

static void *itimer_thread_func(void *_handle_tick)
{
    TickProc handle_tick = _handle_tick;
    uint64_t nticks;
    int timerfd = -1;

#if defined(USE_TIMERFD_FOR_ITIMER) && USE_TIMERFD_FOR_ITIMER
    struct itimerspec it;
    it.it_value.tv_sec  = TimeToSeconds(itimer_interval);
    it.it_value.tv_nsec = TimeToNS(itimer_interval) % 1000000000;
    it.it_interval = it.it_value;

    timerfd = timerfd_create(CLOCK_MONOTONIC, TFD_CLOEXEC);
    if (timerfd == -1) {
        sysErrorBelch("timerfd_create");
        stg_exit(EXIT_FAILURE);
    }
    if (!TFD_CLOEXEC) {
      fcntl(timerfd, F_SETFD, FD_CLOEXEC);
    }
    if (timerfd_settime(timerfd, 0, &it, NULL)) {
        sysErrorBelch("timerfd_settime");
        stg_exit(EXIT_FAILURE);
    }
#endif

    while (!exited) {
        if (USE_TIMERFD_FOR_ITIMER) {
            if (read(timerfd, &nticks, sizeof(nticks)) != sizeof(nticks)) {
                if (errno != EINTR) {
                    sysErrorBelch("Itimer: read(timerfd) failed");
                }
            }
        } else {
            if (usleep(TimeToUS(itimer_interval)) != 0 && errno != EINTR) {
                sysErrorBelch("usleep(TimeToUS(itimer_interval) failed");
            }
        }

        // first try a cheap test
        if (stopped) {
            ACQUIRE_LOCK(&mutex);
            // should we really stop?
            if (stopped) {
                waitCondition(&start_cond, &mutex);
            }
            RELEASE_LOCK(&mutex);
        } else {
            handle_tick(0);
        }
    }

    if (USE_TIMERFD_FOR_ITIMER)
        close(timerfd);
    closeMutex(&mutex);
    closeCondition(&start_cond);
    return NULL;
}
開發者ID:AaronFriel,項目名稱:ghc,代碼行數:58,代碼來源:Pthread.c

示例15: waitCondition

bool
waitCondition ( Condition* pCond, Mutex* pMut )
{
  RELEASE_LOCK(pMut);
  WaitForSingleObject(*pCond, INFINITE);
  /* Hmm..use WaitForMultipleObjects() ? */
  ACQUIRE_LOCK(pMut);
  return true;
}
開發者ID:bgamari,項目名稱:ghc,代碼行數:9,代碼來源:OSThreads.c


注:本文中的ACQUIRE_LOCK函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。