Пример #1
0
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;
}
Пример #2
0
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;
}
Пример #3
0
void NotifyLoopThread(MSG *pMsg)
  {
  ULONG ulPostCount;

  DosResetEventSem(hevNotifyLoopSem,&ulPostCount);
  pMsg = pNotifyLoopMsg;
  while (1)
    {
    pMsg->ulMessageNumber = ulMessageNumber++;
    SendMessage(pMsg);
    DosWaitEventSem(hevNotifyLoopSem,5000);
//    DosSleep(300);
    DosResetEventSem(hevNotifyLoopSem,&ulPostCount);
    }
  }
Пример #4
0
void vlc_sem_wait (vlc_sem_t *sem)
{
    ULONG rc;

    do
    {
        vlc_testcancel ();

        DosRequestMutexSem(sem->wait_mutex, SEM_INDEFINITE_WAIT);

        rc = vlc_WaitForSingleObject (sem->hev, SEM_INDEFINITE_WAIT );

        if (!rc)
        {
            DosRequestMutexSem(sem->count_mutex, SEM_INDEFINITE_WAIT);

            sem->count--;
            if (sem->count == 0)
            {
                ULONG ulPost;

                DosResetEventSem(sem->hev, &ulPost);
            }

            DosReleaseMutexSem(sem->count_mutex);
        }

        DosReleaseMutexSem(sem->wait_mutex);
    } while (rc == ERROR_INTERRUPT);
}
Пример #5
0
VOID APIENTRY ControlFunc( ULONG parm )
{
    ULONG   ulCount;

    parm = parm;
    do {
        DosWaitEventSem( Requestsem, SEM_INDEFINITE_WAIT ); // wait for Request
        DosResetEventSem( Requestsem, &ulCount );
        switch( Req ) {
        case REQ_GO:
            Go( true );
            break;
        case REQ_TRACE_OVER:
            ExecTrace( TRACE_OVER, DbgLevel );
            break;
        case REQ_TRACE_INTO:
            ExecTrace( TRACE_INTO, DbgLevel );
            break;
        }
        DoInput();
        _SwitchOff( SW_TASK_RUNNING );
        DosPostEventSem( Requestdonesem );
    } while( Req != REQ_BYE );
    return; // thread over!
}
Пример #6
0
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;
}
Пример #7
0
int GetPipeEvent(TEvent *Event) {
  ULONG ulPostCount;
  int   i;

  Event->What = evNone;

  for (i = 0; i < MAX_PIPES; i++) {
    if (Pipes[i].used == 0) continue;

    if (Pipes[i].notify == 0) continue;

    if (DosResetEventSem(Pipes[i].NewData, &ulPostCount) != 0) continue;

    if (ulPostCount > 0) {
      // fprintf(stderr, "Pipe New Data: %d\n", i);
      Event->What        = evNotify;
      Event->Msg.View    = 0;
      Event->Msg.Model   = Pipes[i].notify;
      Event->Msg.Command = cmPipeRead;
      Event->Msg.Param1  = i;
      return 1;
    }
  }
  return 0;
}
Пример #8
0
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);
}
Пример #9
0
VOID PumpMessageQueue( VOID )
{
    char        class_name[80];
    QMSG        qmsg;
    ERRORID     err;
    ULONG       ulCount;

    for( ;; ) {
        DosWaitEventSem( PumpMessageSem, SEM_INDEFINITE_WAIT );
        DosResetEventSem( PumpMessageSem, &ulCount );
        WinThreadAssocQueue( GUIGetHAB(), GUIPMmq );
        while ( WinGetMsg( GUIGetHAB(), &qmsg, 0L, 0, 0 ) ) {
            WinQueryClassName( qmsg.hwnd, sizeof( class_name ), class_name );
            if (strcmp( class_name, "GUIClass" ) == 0 ||
                strcmp( class_name, "WTool" ) == 0) {
                WinDefWindowProc( qmsg.hwnd, qmsg.msg, qmsg.mp1, qmsg.mp2 );
            } else {
                WinDispatchMsg( GUIGetHAB(), &qmsg );
            }
        }
        WinThreadAssocQueue( GUIGetHAB(), NULL );
        err = WinGetLastError( GUIGetHAB() );
        DosPostEventSem( PumpMessageDoneSem );
    }
}
Пример #10
0
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();
}
Пример #11
0
unsigned long Event::Reset ( ) {

   if ( Handle == 0 )
      return ( (unsigned long) 0xFFFFFFFF ) ;

   if ( DebugFlag ) Log ( "Event(%s)::Reset.", Tag?Tag:"" ) ;

   BOOL Result = FALSE ;

   #ifdef __OS2__

      ULONG PostCount ;
      APIRET Status = DosResetEventSem ( Handle, &PostCount ) ;
      if ( Status && ( Status != ERROR_ALREADY_RESET ) )
         Result = FALSE ;
      else
         Result = TRUE ;

   #else

      Result = ResetEvent ( Handle ) ;

   #endif

   return ( Result ) ;

} /* endmethod */
Пример #12
0
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);
}
Пример #13
0
/* reset_async_info clear async_info in such a way that fresh add_waiter()
 * calls can be performed.
 */
static void Os2_reset_async_info(void *async_info)
{
   AsyncInfo *ai = async_info;
   ULONG ul;

   DosResetEventSem(ai->sem, &ul);
   ai->mustwait = 0;
}
Пример #14
0
static void BeginSoftModeThread( thread_data *arglist )
{
    TID         tid;
    ULONG       ulCount;

    DosResetEventSem( BeginThreadSem , &ulCount );
    DosCreateThread( &tid, BeginThreadHelper, (ULONG)arglist, 0, STACK_SIZE );
    DosWaitEventSem( BeginThreadSem, SEM_INDEFINITE_WAIT );
}
Пример #15
0
void APIENTRY ReadLoopThread()
  {
  THREAD *pstThd = pstThread;
  CONFIG *pCfg = &pstThd->stCfg;
  THREADCTRL *pThread = &pstThd->stThread;
  BOOL bReadComplete;
  CHAR *pString;
  APIRET rc;
  BOOL bSkipRead = FALSE;
  char szMessage[80];
  ULONG ulStringLength;
  ULONG ulPostCount;


//  DosSetPriority(PRTYS_THREAD,PRTYC_FOREGROUNDSERVER,-28L,0);
  DosSetPriority(PRTYS_THREAD,PRTYC_REGULAR,-10L,0);
  ulStringLength = pCfg->wReadStringLength;
  DosAllocMem((PPVOID)&pString,10010,(PAG_COMMIT | PAG_WRITE | PAG_READ));
  while (!pThread->bStopThread)
    {
    if (ulStringLength != pCfg->wReadStringLength)
      {
      DosFreeMem(pString);
      ulStringLength = pCfg->wReadStringLength;
      DosAllocMem((PPVOID)&pString,(ulStringLength + 10),(PAG_COMMIT | PAG_WRITE | PAG_READ));
      }
    if (pCfg->bHalfDuplex)
      {
      while ((rc = DosWaitEventSem(hevStartReadSem,10000)) != 0)
        if (rc == ERROR_SEM_TIMEOUT)
          {
          ErrorNotify(pstThd,"Read start semaphore timed out");
          bSkipRead = TRUE;
          }
        else
          {
          sprintf(szMessage,"Read start semaphore error - rc = %u",rc);
          ErrorNotify(pstThd,szMessage);
          }
      DosResetEventSem(hevStartReadSem,&ulPostCount);
      }
    if (bSkipRead)
      bSkipRead = FALSE;
    else
      {
      if (!pCfg->bReadCharacters)
        bReadComplete = ReadString(pstThd,pString);
      else
        bReadComplete = ReadCharacters(pstThd,pString);
      if (bReadComplete)
        DosPostEventSem(hevStartWriteSem);
      }
    }
  DosFreeMem(pString);
  DosPostEventSem(hevKillReadThreadSem);
  DosExit(EXIT_THREAD,0);
  }
Пример #16
0
static int write_os2(audio_output_t *ao,unsigned char *buf,int len)
{
	/* if we're too quick, let's wait */
	if(nobuffermode)
	{
		MCI_MIX_BUFFER *temp = playingbuffer;
		
		while(
			(tobefilled != (temp = ((BUFFERINFO *) temp->ulUserParm)->NextBuffer)) &&
			(tobefilled != (temp = ((BUFFERINFO *) temp->ulUserParm)->NextBuffer)) &&
			(tobefilled != (temp = ((BUFFERINFO *) temp->ulUserParm)->NextBuffer)) )
		{
			DosResetEventSem(dataplayed,&resetcount);
			DosWaitEventSem(dataplayed, -1);
			temp = playingbuffer;
		}
		
	} else {
		while(tobefilled == playingbuffer)
		{
			DosResetEventSem(dataplayed,&resetcount);
			DosWaitEventSem(dataplayed, -1);
		}
	}
		
	if (justflushed) {
		justflushed = FALSE;
	} else {
		nomoredata = FALSE;
		
		memcpy(tobefilled->pBuffer, buf, len);
		tobefilled->ulBufferLength = len;
		//      ((BUFFERINFO *) tobefilled->ulUserParm)->frameNum = fr->frameNum;
		
		/* if we're out of the water (3rd ahead buffer filled),
		let's reduce our priority */
		if(tobefilled == ( (BUFFERINFO *) ( (BUFFERINFO *) ((BUFFERINFO *) playingbuffer->ulUserParm)->NextBuffer->ulUserParm)->NextBuffer->ulUserParm)->NextBuffer)
			DosSetPriority(PRTYS_THREAD,normalclass,normaldelta,mainthread->tib_ptib2->tib2_ultid);
		
		tobefilled = ((BUFFERINFO *) tobefilled->ulUserParm)->NextBuffer;
	}
	
	return len;
}
Пример #17
0
int os2KbdQueueQuery()
{
	ULONG numElements,postCount;
 
	(void)DosQueryQueue(hKbdQueue,&numElements);
	if (numElements!=0) return 0; /* We have something in queue */

	DosResetEventSem(hKbdSem,&postCount);
	return 1;
}
Пример #18
0
//***************************************************************************
//*                                                                         *
//*  BOOL waitPost()                                                        *
//*                                                                         *
//*  Waits for postSema being posted by device driver                       *
//*  Returns:                                                               *
//*    TRUE - Success                                                       *
//*    FALSE - Unsuccessful access of event semaphore                       *
//*                                                                         *
//*  Preconditions: init() has to be called successfully before             *
//*                                                                         *
//***************************************************************************
BOOL scsiObj::waitPost()
{
  ULONG count=0;
  ULONG rc;                                             // return value

  rc = DosWaitEventSem(postSema, -1);                   // wait forever
  if (rc) return FALSE;                                 // DosWaitEventSem failed
  rc = DosResetEventSem(postSema, &count);              // reset semaphore
  if (rc) return FALSE;                                 // DosResetEventSem failed
  return TRUE;
}
Пример #19
0
static ULONG
wait_post(ULONG ulTimeOut)
{
	ULONG count = 0;
	ULONG rc;					/* return value */

/*	rc = DosWaitEventSem(postSema, -1);*/		/* wait forever*/
	rc = DosWaitEventSem(postSema, ulTimeOut);
	DosResetEventSem(postSema, &count);
	return (rc);
}
Пример #20
0
void RunRequest( int req )
{
    ULONG   ulCount;

    if( _IsOn( SW_TASK_RUNNING ) ) return;
    DosWaitEventSem( Requestdonesem, SEM_INDEFINITE_WAIT ); // wait for last request to finish
    DosResetEventSem( Requestdonesem, &ulCount );
    Req = req;
    _SwitchOn( SW_TASK_RUNNING );
    DosPostEventSem( Requestsem ); // tell worker to go
}
Пример #21
0
PRStatus
_PR_MD_WAIT(PRThread *thread, PRIntervalTime ticks)
{
    PRInt32 rv;
    ULONG count;

    PRUint32 msecs = (ticks == PR_INTERVAL_NO_TIMEOUT) ?
        SEM_INDEFINITE_WAIT : PR_IntervalToMilliseconds(ticks);
    rv = DosWaitEventSem(thread->md.blocked_sema, msecs);
    DosResetEventSem(thread->md.blocked_sema, &count); 
    switch(rv) 
    {
        case NO_ERROR:
            return PR_SUCCESS;
            break;
        case ERROR_TIMEOUT:
            _PR_THREAD_LOCK(thread);
            if (thread->state == _PR_IO_WAIT) {
			  ;
            } else {
                if (thread->wait.cvar != NULL) {
                    thread->wait.cvar = NULL;
                    _PR_THREAD_UNLOCK(thread);
                } else {
                    /* The CVAR was notified just as the timeout
                     * occurred.  This led to us being notified twice.
                     * call SemRequest() to clear the semaphore.
                     */
                    _PR_THREAD_UNLOCK(thread);
                    rv = DosWaitEventSem(thread->md.blocked_sema, 0);
                    DosResetEventSem(thread->md.blocked_sema, &count); 
                    PR_ASSERT(rv == NO_ERROR);
                }
            }
            return PR_SUCCESS;
            break;
        default:
            break;
    }
    return PR_FAILURE;
}
Пример #22
0
ULONG CommandSTOP(  PLUGINWORK *pPluginWork, DECODER_PARAMS *pParams )
{
    ULONG ulTmp;

    if(pPluginWork->fStatus == 0) {
        return 101;
    }
    DosResetEventSem( pPluginWork->hevThreadA, &ulTmp );
    pPluginWork->fStop = TRUE;
    DosWaitEventSem( pPluginWork->hevThreadA, 20000 );
    return 0;
}
/****************************************************************\
 * 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;
}
Пример #24
0
ULONG CommandPLAY(  PLUGINWORK *pPluginWork, DECODER_PARAMS *pParams )
{
    ULONG ulTmp;

    if(pPluginWork->fStatus != 0) {
        return 101;
    }
    strncpy( pPluginWork->szFileName, pParams->filename, 4096 );
    DosResetEventSem( pPluginWork->hevThreadA, &ulTmp );
    DosPostEventSem( pPluginWork->hevThreadTrigger );
    DosWaitEventSem( pPluginWork->hevThreadA, 20000 );
    
    return 0;
}
Пример #25
0
void fly_init (int x0, int y0, int rows, int cols, char *font)
{
    TID       tid;
    int       rc;
    ULONG     reset;

    tiled1 = _tmalloc (tiled_size);
    if (tiled1 == NULL) fly_error ("cannot allocate tiled memory\n");
    us1_16 = _tmalloc (sizeof(USHORT));
    us2_16 = _tmalloc (sizeof(USHORT));
    pci = _tmalloc (sizeof(VIOCURSORINFO));

    rc = DosCreateMutexSem (NULL, &mtx_Queue, 0, FALSE);
    debug_tools ("rc = %d after DosCreateMutexSem\n", rc);

    rc = DosCreateMutexSem (NULL, &mtx_Video, 0, FALSE);
    debug_tools ("rc = %d after DosCreateMutexSem\n", rc);

    rc = DosCreateEventSem (NULL, &hev_NewMessage, 0, FALSE);
    debug_tools ("rc = %d after DosCreateEventSem\n", rc);

    rc = DosCreateEventSem (NULL, &hev_VideoReady, 0, FALSE);
    debug_tools ("rc = %d after DosCreateEventSem\n", rc);
    
    grab_video ();
    if (rows != -1 && cols != -1)
        video_init (rows, cols);
    else
        video_init (25, 80);
    release_video ();

    DosResetEventSem (hev_VideoReady, &reset);
    rc = DosCreateThread (&tid, interface_thread, 0, 0, 32786);
    debug_tools ("rc = %d after DosCreateThread\n", rc);

    DosWaitEventSem (hev_VideoReady, SEM_INDEFINITE_WAIT);
    fl_opt.initialized = TRUE;
    DosSleep (300);

    if (font != NULL)
        fly_set_font (font);

    //debug_tools ("rows = %d, cols = %d in fly_init\n", rows, cols);
    if (rows != -1 && cols != -1)
        video_set_window_size (rows, cols);
    
    debug_tools ("x0 = %d, y0 = %d in fly_init\n", x0, y0);
    if (x0 >= 0 && y0 >= 0)
        video_set_window_pos (x0, y0);
}
Пример #26
0
void DART_WaitDone(_THIS)
{
  pMixBufferDesc pBufDesc;
  ULONG ulPostCount;
  APIRET rc;

  pBufDesc = (pMixBufferDesc) _this->hidden->pMixBuffers[_this->hidden->iLastPlayedBuf].ulUserParm;
  rc = NO_ERROR;
  while ((pBufDesc->iBufferUsage != BUFFER_EMPTY) && (rc==NO_ERROR))
  {
    DosResetEventSem(_this->hidden->hevAudioBufferPlayed, &ulPostCount);
    rc = DosWaitEventSem(_this->hidden->hevAudioBufferPlayed, 1000); 
  }
}
Пример #27
0
void TEventQueue::getMouseState( TEvent & ev )
{
#ifdef __NT__
  ev.mouse.where   = lastMouse.where;
  ev.mouse.buttons = lastMouse.buttons;
  if ( lastMouse.buttons != 0 ) ev.what = getTicks();  // Temporarily save tick count when event was read.

  INPUT_RECORD *irp = TThreads::get_next_event();
  if ( irp == NULL || irp->EventType != MOUSE_EVENT ) return;
  TThreads::accept_event();
  curMouse.where.x = irp->Event.MouseEvent.dwMousePosition.X;
  curMouse.where.y = irp->Event.MouseEvent.dwMousePosition.Y;
  curMouse.buttons = irp->Event.MouseEvent.dwButtonState;
  curMouse.doubleClick = (irp->Event.MouseEvent.dwEventFlags & DOUBLE_CLICK)
                                ? True
                                : False;
  ev.mouse = curMouse;
  if ( lastMouse.buttons == 0 ) ev.what = getTicks();
#else   // __NT__
#ifdef __OS2__
    assert(! DosRequestMutexSem(TThreads::hmtxMouse1,SEM_INDEFINITE_WAIT) );
#else
    _disable();
#endif
    if( eventCount == 0 )
        {
        ev.what = getTicks();
        ev.mouse = curMouse;
        }
    else
        {
        ev = *eventQHead;
        if( ++eventQHead >= eventQueue + eventQSize )
            eventQHead = eventQueue;
        eventCount--;
        }
#ifdef __OS2__
    if (eventCount==0) {
      ULONG dummy;
      DosResetEventSem( TThreads::hevMouse1, &dummy );
    };
    assert(! DosReleaseMutexSem(TThreads::hmtxMouse1) );
#else
    _enable();
#endif  // __OS2__
#endif  // __NT__
    if( mouseReverse != False && ev.mouse.buttons != 0 && ev.mouse.buttons != 3 )
        ev.mouse.buttons ^= 3;
}
Пример #28
0
APIRET APIENTRY thSwitch (void)
   {
   BOOL  bSuccess;
   ULONG ul;

   do {
      DosResetEventSem (hevSammy, &ul);
      DosWaitEventSem (hevSammy, SEM_INDEFINITE_WAIT);
      bSuccess = ChangeWPS(pShareInitOS2->pszUserIni, pShareInitOS2->pszSystemIni);
      DebugULd (1, "thSwitch", "bSuccess", bSuccess);
      }
   while( bSuccess );

   return 0;
   }
Пример #29
0
unsigned OnAnotherThread( unsigned(*rtn)(unsigned,void *,unsigned,void *), unsigned in_len, void *in, unsigned out_len, void *out )
{
    unsigned    result;
    ULONG       ulCount;

    if( !ToldWinHandle || IsTrapFilePumpingMessageQueue() ) {
        return rtn( in_len, in, out_len, out );
    } else {
        DosPostEventSem( PumpMessageSem );
        result = rtn( in_len, in, out_len, out );
        WinPostMsg( GUIGetSysHandle( WndGui( WndMain ) ), WM_QUIT, 0, 0 );
        DosWaitEventSem( PumpMessageDoneSem, SEM_INDEFINITE_WAIT );
        DosResetEventSem( PumpMessageDoneSem, &ulCount );
        return result;
    }
}
Пример #30
0
RTDECL(int)  RTSemEventMultiReset(RTSEMEVENTMULTI hEventMultiSem)
{
    /*
     * Reset the object.
     */
    ULONG ulIgnore;
    int rc = DosResetEventSem(SEM2HND(hEventMultiSem), &ulIgnore);
    switch (rc)
    {
        case NO_ERROR:
        case ERROR_ALREADY_RESET:
            return VINF_SUCCESS;
        default:
            return RTErrConvertFromOS2(rc);
    }
}