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


C++ DosWaitEventSem函数代码示例

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


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

示例1: getmessage

int getmessage (int interval)
{
    int             key = 0;
    ULONG           posted;

    if (que_n() > 0) return que_get ();
    
    // with interval == 0, we only check for keys in buffer
    if (interval == 0)
    {
        key = 0;
    }
    else if (interval > 0)
    {
        DosResetEventSem (hev_NewMessage, &posted);
        DosWaitEventSem (hev_NewMessage, interval);
        key = que_get ();
    }
    else if (interval < 0)
    {
        DosResetEventSem (hev_NewMessage, &posted);
        DosWaitEventSem (hev_NewMessage, SEM_INDEFINITE_WAIT);
        key = que_get ();
    }
    return key;
}
开发者ID:OS2World,项目名称:LIB-libfly,代码行数:26,代码来源:os2pm.c

示例2: PipeWaitAndResetEventSem

static APIRET PipeWaitAndResetEventSem(HEV *SemHandle)
{
#define EVENTSEM_TIMEOUT SEM_INDEFINITE_WAIT

	APIRET rc;
	ULONG PostCt;

	rc = DosWaitEventSem(*SemHandle, EVENTSEM_TIMEOUT);
	if (!rc) rc = DosResetEventSem(*SemHandle, &PostCt);

	if (rc == ERROR_INVALID_HANDLE)
	{
		rc = DosOpenEventSem(0, SemHandle);

		if (!rc) 
		{
		    rc = DosWaitEventSem(*SemHandle, EVENTSEM_TIMEOUT);
		    if (!rc) rc = DosResetEventSem(*SemHandle, &PostCt);
		}
	}

        if (rc == ERROR_ALREADY_RESET) rc = 0;

	return rc;
}
开发者ID:OS2World,项目名称:UTIL-MEMORY-MemLink,代码行数:25,代码来源:PIPES.C

示例3: ThreadConsumer

/****************************************************************\
 * Routine for consumer threads.                                *
 *--------------------------------------------------------------*
 *                                                              *
 *  Name:     ThreadConsumer(PVOID)                             *
 *                                                              *
 *  Purpose:  There are NUMUSERS copies of this thread to act   *
 *            as consumers of the resource. The thread waits for*
 *            exclusive access to the resource and colors it.   *
 *                                                              *
 *  Usage:    Threads created by StartSemExample.               *
 *                                                              *
 *  Method:   Waits for mutex to gain ownership of resource.    *
 *            Releases resource when user event. Dies when      *
 *            Stop event.                                       *
 *  Returns:                                                    *
 *                                                              *
\****************************************************************/
VOID ThreadConsumer( PVOID pvMyID )
{
   ULONG  ulPostCnt;
   ULONG  ulUser=0L;
   ULONG  rc;
   HAB    habb;
   HMQ    hmqq;

   /* Need a message queue for any thread that wants to print messages. */
   habb = WinInitialize(0);
   hmqq = WinCreateMsgQueue(habb,0);

   /* while the user has not selected stop ... */
   while ((DosWaitEventSem(hevStop,SEM_IMMEDIATE_RETURN)) == ERROR_TIMEOUT)
   {
      /* Wait for exclusive ownership of resource */

      DosRequestMutexSem(hmtxOwnResource,SEM_INDEFINITE_WAIT);

      /* the following check is necessary because the stop semaphore
       * may have been posted  while we were waiting on the mutex
       */
      if (DosWaitEventSem(hevStop, SEM_IMMEDIATE_RETURN) == ERROR_TIMEOUT)
      {
      /*********************************************************************\
       * an item is ready, which one?  don't wait forever because there is *
       * a possibility that the stop semaphore was posted and that no more *
       * resource is forthcoming. we wait twice as long as we think is     *
       * necessary.                                                        *
      \*********************************************************************/
         if (!DosWaitMuxWaitSem (hmuxResource, max (ulTimeout << 1,
            TIMEOUTPERIOD) , &ulUser))
         {
            MyMove ((ULONG) pvMyID, ulUser);
            DosResetEventSem(aSquares[ulUser].hev, &ulPostCnt);
         }
      }
                               /* Let some other thread have resource. */
      rc = DosReleaseMutexSem(hmtxOwnResource);
      if (rc)
      {
         SemError("DosReleaseMutexSem",rc);
      }
   }
   /* hevStop was posted, kill this thread */
   WinDestroyMsgQueue (hmqq);
   WinTerminate (habb);
   DosExit(EXIT_THREAD, 0);
   return;
}
开发者ID:MbqIIB,项目名称:DEV-SAMPLES-IBM_Dev_Toolkit_Samples,代码行数:68,代码来源:semaph.c

示例4: assert

	/* virtual */ void WaitForSignal()
	{
		assert(this->recursive_count == 1); // Do we need to call Begin/EndCritical multiple times otherwise?
		this->EndCritical();
		DosWaitEventSem(event, SEM_INDEFINITE_WAIT);
		this->BeginCritical();
	}
开发者ID:Latexi95,项目名称:openttd,代码行数:7,代码来源:thread_os2.cpp

示例5: SysWaitEventSem

unsigned long SysWaitEventSem(unsigned char *name,
                           unsigned long numargs,
                           RXSTRING args[],
                           char *queuename,
                           RXSTRING *retstr)
{
    unsigned long rc;
    unsigned long timeout = SEM_INDEFINITE_WAIT; /* timeout value default */

    HEV handle = NULL;           /* mutex handle */

#ifdef DLOGGING
    logmessage(__func__);
#endif

    if (numargs < 1 || numargs > 2 || !RXVALIDSTRING(args[0]))
        return INVALID_ROUTINE;

    if (numargs == 2) {
        if (!string2ulong(args[1].strptr, &timeout)) return INVALID_ROUTINE;
    }

    if (!string2ulong(args[0].strptr, &handle)) return INVALID_ROUTINE;

    rc = DosWaitEventSem(handle, timeout);

    RETVAL(rc)
}
开发者ID:OS2World,项目名称:LIB-REXX-REXX_Utilities,代码行数:28,代码来源:syseventsem.c

示例6: avcodec_thread_execute

int avcodec_thread_execute(AVCodecContext *s, int (*func)(AVCodecContext *c2, void *arg2),void *arg, int *ret, int count, int size){
    ThreadContext *c= s->thread_opaque;
    int i;

    assert(s == c->avctx);
    assert(count <= s->thread_count);

    /* note, we can be certain that this is not called with the same AVCodecContext by different threads at the same time */

    for(i=0; i<count; i++){

        c[i].arg= (char*)arg + i*size;
        c[i].func= func;
        c[i].ret= 12345;

        DosPostEventSem(c[i].work_sem);
//        ReleaseSemaphore(c[i].work_sem, 1, 0);
    }
    for(i=0; i<count; i++){
        DosWaitEventSem(c[i].done_sem,SEM_INDEFINITE_WAIT);
//        WaitForSingleObject(c[i].done_sem, INFINITE);

        c[i].func= NULL;
        if(ret) ret[i]= c[i].ret;
    }
    return 0;
}
开发者ID:Acidburn0zzz,项目名称:ffmpeg-concat,代码行数:27,代码来源:os2thread.c

示例7: Os2_wait_async_info

/* wait_async_info waits for some handles to become ready. This function
 * returns if at least one handle becomes ready.
 * A handle can be added with add_async_waiter to the bundle of handles to
 * wait for.
 * No special handling is implemented if an asyncronous interrupt occurs.
 * Thus, there is no guarantee to have handle which works.
 */
static void Os2_wait_async_info(void *async_info)
{
   AsyncInfo *ai = async_info;

   if (ai->mustwait)
      DosWaitEventSem(ai->sem, SEM_INDEFINITE_WAIT);
}
开发者ID:ErisBlastar,项目名称:osfree,代码行数:14,代码来源:os_os2.c

示例8: GetClipText

int GetClipText(ClipData *cd) {
    int rc;
    ULONG PostCount;
    char *mem;
    
    rc = DosOpenMutexSem(SEM_PREFIX "CLIPSYN", &hmtxSyn);
    if (rc != 0) return -1;
    rc = DosOpenEventSem(SEM_PREFIX "CLIPGET", &hevGet);
    if (rc != 0) return -1;
/*    rc = DosOpenEventSem(SEM_PREFIX "CLIPPUT", &hevPut);*/
/*    if (rc != 0) return -1;*/
    rc = DosOpenEventSem(SEM_PREFIX "CLIPEND", &hevEnd);
    if (rc != 0) return -1;
    
    DosRequestMutexSem(hmtxSyn, SEM_INDEFINITE_WAIT);
    DosResetEventSem(hevEnd, &PostCount);
    DosPostEventSem(hevGet);
    DosWaitEventSem(hevEnd, SEM_INDEFINITE_WAIT);
    if (0 == DosGetNamedSharedMem((void **)&mem, MEM_PREFIX "CLIPDATA", PAG_READ | PAG_WRITE)) {
        cd->fLen = *(ULONG*)mem;
        cd->fChar = strdup(mem + 4);
        DosFreeMem(mem);
    } else {
        cd->fLen = 0;
        cd->fChar = 0;
    }
    DosPostEventSem(hevGet);
    DosReleaseMutexSem(hmtxSyn);
/*    DosCloseEventSem(hevPut);*/
    DosCloseEventSem(hevGet);
    DosCloseEventSem(hevEnd);
    DosCloseMutexSem(hmtxSyn);
    return 0;
}
开发者ID:OS2World,项目名称:APP-EDITOR-fte,代码行数:34,代码来源:clip_vio.cpp

示例9: ThdDskPerf

VOID APIENTRY ThdDskPerf( ULONG ulTask )
{
  int k;
  PDTV pDisk;

  pDisk = (PDTV)ulTask;

  pDisk->szDir[ 6 ] = (char)( pDisk->ulTask + 0x30 );
  pDisk->szDir[ 7 ] = 0;

  setdisk( (int)( pDisk->szDrive[ 0 ] - 'A' ) );
  mkdir( pDisk->szDir );
  chdir( pDisk->szDir );

  /* create test files */
  DosPostEventSem( pDisk->hevReady );

  /* start timing */
  DosWaitEventSem( hevGo, SEM_INDEFINITE_WAIT );

  /* perform string of file operations */
  for( k = 0; k < ITER; k++ )
    readswrites( pDisk );

  /*stop timimg*/
  EndItAll( 0, pDisk );
}
开发者ID:OS2World,项目名称:UTIL-BENCHMARK-MDisk,代码行数:27,代码来源:DISKTHD.C

示例10: Open

/**
 * This function initializes KVA vout method.
 */
static int Open ( vlc_object_t *object )
{
    vout_display_t *vd = (vout_display_t *)object;
    vout_display_sys_t *sys;

    vd->sys = sys = calloc( 1, sizeof( *sys ));
    if( !sys )
        return VLC_ENOMEM;

    DosCreateEventSem( NULL, &sys->ack_event, 0, FALSE );

    sys->tid = _beginthread( PMThread, NULL, 1024 * 1024, vd );
    DosWaitEventSem( sys->ack_event, SEM_INDEFINITE_WAIT );

    if( sys->i_result != VLC_SUCCESS )
    {
        DosCloseEventSem( sys->ack_event );

        free( sys );

        return VLC_EGENERIC;
    }

    return VLC_SUCCESS;
}
开发者ID:fabsther,项目名称:vlc-mort,代码行数:28,代码来源:kva.c

示例11: DosRequestMutexSem

void omni_condition::wait(void)
{
    _internal_omni_thread_helper me;

    DosRequestMutexSem( crit , SEM_INDEFINITE_WAIT );

    me->cond_next = NULL;
    me->cond_prev = waiting_tail;
    if (waiting_head == NULL)
    waiting_head = me;
    else
    waiting_tail->cond_next = me;
    waiting_tail = me;
    me->cond_waiting = TRUE;

    DosReleaseMutexSem( crit );

    mutex->unlock();

    APIRET result =  DosWaitEventSem(me->cond_semaphore, SEM_INDEFINITE_WAIT);
    ULONG c;
    DosResetEventSem(me->cond_semaphore,&c);

    mutex->lock();

    if (result != 0) throw omni_thread_fatal(result);
}
开发者ID:OS2World,项目名称:APP-INTERNET-PMVNC-Server,代码行数:27,代码来源:os2.cpp

示例12: while

void TEventQueue::keyboardThread( void * arg ) {
  arg = arg;
  KBDKEYINFO *info = &TThreads::tiled->keyboardInfo;

  while (1) {
    jsSuspendThread
    USHORT errCode = KbdCharIn( info, IO_NOWAIT, 0 );
    jsSuspendThread
    if ( errCode || (info->fbStatus & 0xC0)!=0x40 || info->fbStatus & 1) { // no char
      keyboardEvent.what = evNothing;
      DosSleep(keyboardPollingDelay);
      if (keyboardPollingDelay < 500) keyboardPollingDelay += 5;
    } else {
    keyboardEvent.what = evKeyDown;

    if ((info->fbStatus & 2) && (info->chChar==0xE0)) info->chChar=0; // OS/2 cursor keys.
    keyboardEvent.keyDown.charScan.charCode=info->chChar;
    keyboardEvent.keyDown.charScan.scanCode=info->chScan;
    shiftState = info->fsState & 0xFF;

    jsSuspendThread

    assert(! DosPostEventSem(TThreads::hevKeyboard1) );

    jsSuspendThread
    assert(! DosWaitEventSem(TThreads::hevKeyboard2, SEM_INDEFINITE_WAIT) );
    keyboardEvent.what = evNothing;
    ULONG dummy;
    jsSuspendThread
    assert(! DosResetEventSem(TThreads::hevKeyboard2, &dummy) );
    keyboardPollingDelay=0;
    }
  }
  TThreads::deadEnd();
}
开发者ID:hackshields,项目名称:antivirus,代码行数:35,代码来源:TEVENT.cpp

示例13: pthread_cond_timedwait

int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
			   struct timespec *abstime)
{
  struct timeb curtime;
  int result;
  long timeout;
   APIRET   rc;
   int	    rval;

   _ftime(&curtime);
   timeout= ((long) (abstime->ts_sec - curtime.time)*1000L +
		    (long)((abstime->ts_nsec/1000) - curtime.millitm)/1000L);
   if (timeout < 0)				/* Some safety */
      timeout = 0L;

   rval = 0;
   cond->waiting++;

   if (mutex) pthread_mutex_unlock(mutex);

   rc = DosWaitEventSem(cond->semaphore, timeout);
   if (rc != 0)
      rval = ETIME;

   if (mutex) pthread_mutex_lock(mutex);

   cond->waiting--;

   return rval;
}
开发者ID:OPSF,项目名称:uClinux,代码行数:30,代码来源:my_os2cond.c

示例14: __CBeginThread

int __CBeginThread( thread_fn *start_addr, void *stack_bottom,
                    unsigned stack_size, void *arglist )
/******************************************************/
{
    TID         tid;
    APIRET      rc;
    thread_args td;

    if( __ThreadData == NULL ) {
        if( __InitThreadProcessing() == NULL )  return( -1 );
        __InitMultipleThread();
    }
    stack_bottom = stack_bottom;
    td.rtn = start_addr;
    td.argument = arglist;
    rc = DosCreateEventSem( NULL, &td.event, 0, 0 );
    if( rc != 0 ) return( -1 );
    rc = DosCreateThread( &tid, (PFNTHREAD)begin_thread_helper, (ULONG)&td,
                          0, stack_size + __threadstksize );
    if( rc != 0 ) {
        tid = -1;
    } else {
        /*
           suspend parent thread so that it can't call _beginthread() again
           before new thread extracts data from "td" (no problem if new
           thread calls _beginthread() since it has its own stack)
        */
        DosWaitEventSem( td.event, SEM_INDEFINITE_WAIT );
    }
    DosCloseEventSem( td.event );
    return( tid );
}
开发者ID:bhanug,项目名称:open-watcom-v2,代码行数:32,代码来源:thredo32.c

示例15: DosWaitEventSem

void omni_semaphore::wait(void)
{
    ULONG cnt;
    APIRET rc = DosWaitEventSem(nt_sem, SEM_INDEFINITE_WAIT);
    if (rc != 0)
    throw omni_thread_fatal(rc);
    DosResetEventSem(nt_sem,&cnt);
}
开发者ID:OS2World,项目名称:APP-INTERNET-PMVNC-Server,代码行数:8,代码来源:os2.cpp


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