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


C++ DosRequestMutexSem函数代码示例

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


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

示例1: vlc_sem_wait

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);
}
开发者ID:CSRedRat,项目名称:vlc,代码行数:30,代码来源:thread.c

示例2: thread_cond_timedwait

static apr_status_t thread_cond_timedwait(apr_thread_cond_t *cond,
                                          apr_thread_mutex_t *mutex,
                                          ULONG timeout_ms )
{
    ULONG rc;
    apr_status_t rv = APR_SUCCESS;
    int wake = FALSE;
    unsigned long generation;

    DosRequestMutexSem(cond->mutex, SEM_INDEFINITE_WAIT);
    cond->num_waiting++;
    generation = cond->generation;
    DosReleaseMutexSem(cond->mutex);

    apr_thread_mutex_unlock(mutex);

    do {
        rc = DosWaitEventSem(cond->semaphore, timeout_ms);

        DosRequestMutexSem(cond->mutex, SEM_INDEFINITE_WAIT);

        if (cond->num_wake) {
            if (cond->generation != generation) {
                cond->num_wake--;
                cond->num_waiting--;
                rv = APR_SUCCESS;
                break;
            } else {
                wake = TRUE;
            }
        }
        else if (rc != 0) {
            cond->num_waiting--;
            rv = APR_TIMEUP;
            break;
        }

        DosReleaseMutexSem(cond->mutex);

        if (wake) {
            wake = FALSE;
            DosPostEventSem(cond->semaphore);
        }
    } while (1);

    DosReleaseMutexSem(cond->mutex);
    apr_thread_mutex_lock(mutex);
    return rv;
}
开发者ID:cmjonze,项目名称:apr,代码行数:49,代码来源:thread_cond.c

示例3: RequestCom

static int RequestCom(void)
{
   USHORT res;
   HMTX sem=0;

   printf("Sending message to AM4PM to release COM port\n");
   res=SendExtQMsg(EQ_RELCOM, NULL, 0);
   if (res)
      return res;

   res=DosOpenMutexSem(szSemCom, &sem);
   if (res)
   {
      printf("Error %u opening semaphore\n", res);
      return 3;
   }

   res=DosRequestMutexSem(sem, 120000l);
   if (res)
   {
      DosCloseMutexSem(sem);
      if (res==ERROR_TIMEOUT)
      {
         printf("Timeout waiting for AM4PM to release COM port\n");
         return 4;
      }
      printf("Error %u waiting for semaphore\n", res);
      return 3;
   }

   DosReleaseMutexSem(sem);
   DosCloseMutexSem(sem);
   return 0;
}
开发者ID:OS2World,项目名称:APP-COMM-AM4PM,代码行数:34,代码来源:am4pmcmd.c

示例4: dump_buffer

static void dump_buffer (int i)
{
    static int index = 0;
    void *b;

    b = buffer;

    if (index + i > bsize) {

        do {
            DosRequestMutexSem (mutex, SEM_INDEFINITE_WAIT);
            if (ready != 0) {
                DosReleaseMutexSem(mutex);
                break;
            }

            DosReleaseMutexSem (mutex);
            DosSleep (20);
        } while (TRUE);

        MixBuffers[next].ulBufferLength = index;
        MixSetupParms.pmixWrite (MixSetupParms.ulMixHandle,
                                 &(MixBuffers[next]),1);
        ready--;
        next++;
        index = 0;

        if (next == BUFFERCOUNT) {
            next=0;
        }
    }

    memcpy (&((char*)MixBuffers[next].pBuffer)[index], b, i);
    index += i;
}
开发者ID:SimonKagstrom,项目名称:sarien-j2me,代码行数:35,代码来源:sound_dart.c

示例5: DosRequestMutexSem

	/* virtual */ void BeginCritical(bool allow_recursive = false)
	{
		/* os2 mutex is recursive by itself */
		DosRequestMutexSem(mutex, (unsigned long) SEM_INDEFINITE_WAIT);
		this->recursive_count++;
		if (!allow_recursive && this->recursive_count != 1) NOT_REACHED();
	}
开发者ID:Latexi95,项目名称:openttd,代码行数:7,代码来源:thread_os2.cpp

示例6: mute

void mute(int state)
{
    ULONG rc;

    if ((rc=DosRequestMutexSem(hmtxOC, SEM_INDEFINITE_WAIT)))
    {
        log_warning(dlog, "mute, DosRequestMutexSem rc=%i", rc);
        return;
    }
    if (usDeviceID)
    {
        MCI_SET_PARMS MciSetParms;

        memset(&MciSetParms, 0, sizeof(MCI_SET_PARMS));

        MciSetParms.ulAudio = MCI_SET_AUDIO_ALL;
        rc = mciSendCommand(usDeviceID, MCI_SET, MCI_WAIT|state|MCI_SET_AUDIO,
                            (PVOID) &MciSetParms, 0);

        if (rc != MCIERR_SUCCESS)
            sound_err(dlog, rc, "Setting mute state (MCI_SET_ON/OFF).");
    }
    DosReleaseMutexSem(hmtxOC);

    if (state==MCI_SET_ON)
        set_volume(volume);
}
开发者ID:BigBoss21X,项目名称:vice-emu,代码行数:27,代码来源:sounddart.c

示例7: os2MutexEnter

/*
** The sqlite3_mutex_enter() and sqlite3_mutex_try() routines attempt
** to enter a mutex.  If another thread is already within the mutex,
** sqlite3_mutex_enter() will block and sqlite3_mutex_try() will return
** SQLITE_BUSY.  The sqlite3_mutex_try() interface returns SQLITE_OK
** upon successful entry.  Mutexes created using SQLITE_MUTEX_RECURSIVE can
** be entered multiple times by the same thread.  In such cases the,
** mutex must be exited an equal number of times before another thread
** can enter.  If the same thread tries to enter any other kind of mutex
** more than once, the behavior is undefined.
*/
static void os2MutexEnter(sqlite3_mutex *p){
  assert( p->id==SQLITE_MUTEX_RECURSIVE || os2MutexNotheld(p) );
  DosRequestMutexSem(p->mutex, SEM_INDEFINITE_WAIT);
#ifdef SQLITE_DEBUG
  if( p->trace ) os2MutexTrace(p, "enter");
#endif
}
开发者ID:77songsong,项目名称:sqlite3,代码行数:18,代码来源:mutex_os2.c

示例8: internal_SetPageFont

static void internal_SetPageFont(HWND hwnd)
{
  char *pchTemp;

  // Set new window fonts!
  if (DosRequestMutexSem(hmtxUseNLSTextArray, SEM_INDEFINITE_WAIT)==NO_ERROR)
  {
    pchTemp = apchNLSText[SSMODULE_NLSTEXT_FONTTOUSE];
    if (pchTemp)
    {
      HWND hwndChild;
      HENUM henum;

      // Oookay, we have the font, set the page and all controls inside it!
      WinSetPresParam(hwnd, PP_FONTNAMESIZE,
		      strlen(pchTemp)+1,
		      pchTemp);

      // Now go through all of its children, and set it there, too!
      henum = WinBeginEnumWindows(hwnd);

      while ((hwndChild = WinGetNextWindow(henum))!=NULLHANDLE)
      {
	WinSetPresParam(hwndChild, PP_FONTNAMESIZE,
			strlen(pchTemp)+1,
			pchTemp);

      }
      WinEndEnumWindows(henum);
    }

    DosReleaseMutexSem(hmtxUseNLSTextArray);
  }
}
开发者ID:OS2World,项目名称:UTIL-WPS-Doodle-Screen-Saver,代码行数:34,代码来源:Text.c

示例9: _cairo_os2_surface_finish

static cairo_status_t
_cairo_os2_surface_finish (void *abstract_surface)
{
    cairo_os2_surface_t *local_os2_surface;

    local_os2_surface = (cairo_os2_surface_t *) abstract_surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        /* Invalid parameter (wrong surface)! */
        return _cairo_error (CAIRO_STATUS_SURFACE_TYPE_MISMATCH);
    }

    DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT);

    /* Destroy old image surface */
    cairo_surface_destroy ((cairo_surface_t *) (local_os2_surface->image_surface));
    /* Destroy old pixel buffer */
    _buffer_free (local_os2_surface->pixels);
    DosCloseMutexSem (local_os2_surface->hmtx_use_private_fields);
    DosCloseEventSem (local_os2_surface->hev_pixel_array_came_back);

    /* The memory itself will be free'd by the cairo_surface_destroy ()
     * who called us.
     */

    return CAIRO_STATUS_SUCCESS;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:28,代码来源:cairo-os2-surface.c

示例10: internal_SetPwdProtWindowText

static void internal_SetPwdProtWindowText(HWND hwnd)
{
  char *pchTemp;

  // Set new window texts!
  if (DosRequestMutexSem(hmtxUseNLSTextArray, SEM_INDEFINITE_WAIT)==NO_ERROR)
  {
    pchTemp = apchNLSText[SSMODULE_NLSTEXT_PWDPROT_ASK_TITLE];
    if (pchTemp)
      WinSetWindowText(hwnd, pchTemp);

    pchTemp = apchNLSText[SSMODULE_NLSTEXT_PWDPROT_ASK_TEXT];
    if (pchTemp)
      WinSetDlgItemText(hwnd, ST_PLEASEENTERTHEPASSWORD, pchTemp);

    pchTemp = apchNLSText[SSMODULE_NLSTEXT_PWDPROT_ASK_OKBUTTON];
    if (pchTemp)
      WinSetDlgItemText(hwnd, PB_OK, pchTemp);

    pchTemp = apchNLSText[SSMODULE_NLSTEXT_PWDPROT_ASK_CANCELBUTTON];
    if (pchTemp)
      WinSetDlgItemText(hwnd, PB_CANCEL, pchTemp);

    DosReleaseMutexSem(hmtxUseNLSTextArray);
  }
}
开发者ID:OS2World,项目名称:UTIL-WPS-Doodle-Screen-Saver,代码行数:26,代码来源:Text.c

示例11: _cairo_os2_surface_release_source_image

static void
_cairo_os2_surface_release_source_image (void                  *abstract_surface,
                                         cairo_image_surface_t *image,
                                         void                  *image_extra)
{
    cairo_os2_surface_t *local_os2_surface;

    local_os2_surface = (cairo_os2_surface_t *) abstract_surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        /* Invalid parameter (wrong surface)! */
        return;
    }

    /* Decrease Lend counter! */
    DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT);

    if (local_os2_surface->pixel_array_lend_count > 0)
        local_os2_surface->pixel_array_lend_count--;
    DosPostEventSem (local_os2_surface->hev_pixel_array_came_back);

    DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);
    return;
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:25,代码来源:cairo-os2-surface.c

示例12: cairo_os2_surface_set_hwnd

/**
 * cairo_os2_surface_set_hwnd:
 * @surface: the cairo surface to associate with the window handle
 * @hwnd_client_window: the window handle of the client window
 *
 * Sets window handle for surface. If Cairo wants to blit into the window
 * because it is set to blit as the surface changes (see
 * cairo_os2_surface_set_manual_window_refresh()), then there are two ways it
 * can choose:
 * If it knows the HWND of the surface, then it invalidates that area, so the
 * application will get a WM_PAINT message and it can call
 * cairo_os2_surface_refresh_window() to redraw that area. Otherwise cairo itself
 * will use the HPS it got at surface creation time, and blit the pixels itself.
 * It's also a solution, but experience shows that if this happens from a non-PM
 * thread, then it can screw up PM internals.
 *
 * So, best solution is to set the HWND for the surface after the surface
 * creation, so every blit will be done from application's message processing
 * loop, which is the safest way to do.
 *
 * Since: 1.4
 **/
void
cairo_os2_surface_set_hwnd (cairo_surface_t *surface,
                            HWND             hwnd_client_window)
{
    cairo_os2_surface_t *local_os2_surface;

    local_os2_surface = (cairo_os2_surface_t *) surface;
    if ((!local_os2_surface) ||
        (local_os2_surface->base.backend != &cairo_os2_surface_backend))
    {
        /* Invalid parameter (wrong surface)! */
        return;
    }

    if (DosRequestMutexSem (local_os2_surface->hmtx_use_private_fields, SEM_INDEFINITE_WAIT)
        != NO_ERROR)
    {
        /* Could not get mutex! */
        return;
    }

    local_os2_surface->hwnd_client_window = hwnd_client_window;

    DosReleaseMutexSem (local_os2_surface->hmtx_use_private_fields);
}
开发者ID:MozillaOnline,项目名称:gecko-dev,代码行数:47,代码来源:cairo-os2-surface.c

示例13: GetExportPluginForFormat

WaWEPlugin_p GetExportPluginForFormat(WaWEExP_Create_Desc_p pFormatDesc)
{
  WaWEPlugin_p pResult = NULL;
  WaWEPlugin_p temp = NULL;
  int iImportance;

  if (DosRequestMutexSem(PluginListProtector_Sem, SEM_INDEFINITE_WAIT)==NO_ERROR)
  {
    // Go through all plugins, in order of importance,
    // and check them if they can open the file.
    // Return the first one, which reports success!
    for (iImportance = WAWE_PLUGIN_IMPORTANCE_MAX;
         iImportance >= WAWE_PLUGIN_IMPORTANCE_MIN;
         iImportance--)
    {
      temp = PluginListHead;
      while ((temp) && (!pResult))
      {
        if ((temp->iPluginType == WAWE_PLUGIN_TYPE_EXPORT) &&
            (temp->iPluginImportance == iImportance))
        {
          if (temp->TypeSpecificInfo.ExportPluginInfo.fnIsFormatSupported(pFormatDesc))
          {
            // Hey, found a plugin which can write in this format!
            pResult = temp;
          }
        }
        temp = temp->pNext;
      }
      if (pResult) break;
    }
    DosReleaseMutexSem(PluginListProtector_Sem);
  }
  return pResult;
}
开发者ID:OS2World,项目名称:MM-SOUND-WaWE,代码行数:35,代码来源:WaWEPlugins.c

示例14: MCIDRVSave

RC MCIDRVSave (FUNCTION_PARM_BLOCK *pFuncBlock)
{
  ULONG                ulrc = MCIERR_SUCCESS;    // Propogated Error Code
  ULONG                ulParam1;                 // Message flags
  PMCI_INFO_PARMS      pInfoParms;               // Pointer to info structure
  PMCI_GENERIC_PARMS   pDrvSaveParms;            // Pointer to GENERIC structure
  PINSTANCE            pInstance;                // Pointer to instance

  /*****************************************************/
  /* dereference the values from pFuncBlock            */
  /*****************************************************/
  ulParam1       = pFuncBlock->ulParam1;
  pInstance      = pFuncBlock->pInstance;
  pDrvSaveParms     = (PMCI_GENERIC_PARMS)pFuncBlock->pParam2;

  /*****************************************************/
  /* NOTE ----->>>                                     */
  /*  This is the basic function that should be        */
  /*  performed.  See the other samples in the toolkit */
  /*  for streaming and MMIO considerations            */
  /*****************************************************/
  DosRequestMutexSem (pInstance->hmtxAccessSem, -2);  // wait for semaphore
  pInstance->Active = FALSE;
  DosReleaseMutexSem (pInstance->hmtxAccessSem);      // release semaphore


  return (ulrc);

}      /* end of MCIDRVSave */
开发者ID:MbqIIB,项目名称:DEV-SAMPLES-IBM_Dev_Toolkit_Samples,代码行数:29,代码来源:mcddrvsv.c

示例15: CreatePluginList

WaWEPluginList_p CreatePluginList(int iPluginType)
{
  WaWEPluginList_p pResult = NULL;
  WaWEPluginList_p pLast = NULL;
  WaWEPluginList_p pNew;
  WaWEPlugin_p temp;

  if (DosRequestMutexSem(PluginListProtector_Sem, SEM_INDEFINITE_WAIT)==NO_ERROR)
  {
    temp = PluginListHead;
    while (temp)
    {
      if (temp->iPluginType == iPluginType)
      {
        pNew = (WaWEPluginList_p) dbg_malloc(sizeof(WaWEPluginList_t));
        if (pNew)
        {
          pNew->pNext = NULL;
          pNew->pPlugin = temp;
          if (!pResult)
          {
            pResult = pNew;
          } else
          {
            pLast->pNext = pNew;
          }
          pLast = pNew;
        }
      }
      temp = temp->pNext;
    }
    DosReleaseMutexSem(PluginListProtector_Sem);
  }
  return pResult;
}
开发者ID:OS2World,项目名称:MM-SOUND-WaWE,代码行数:35,代码来源:WaWEPlugins.c


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