本文整理汇总了C++中DosCloseEventSem函数的典型用法代码示例。如果您正苦于以下问题:C++ DosCloseEventSem函数的具体用法?C++ DosCloseEventSem怎么用?C++ DosCloseEventSem使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了DosCloseEventSem函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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;
}
示例2: vlc_thread_cleanup
static void vlc_thread_cleanup (struct vlc_thread *th)
{
vlc_threadvar_t key;
retry:
/* TODO: use RW lock or something similar */
vlc_mutex_lock (&super_mutex);
for (key = vlc_threadvar_last; key != NULL; key = key->prev)
{
void *value = vlc_threadvar_get (key);
if (value != NULL && key->destroy != NULL)
{
vlc_mutex_unlock (&super_mutex);
vlc_threadvar_set (key, NULL);
key->destroy (value);
goto retry;
}
}
vlc_mutex_unlock (&super_mutex);
if (th->detached)
{
DosCloseEventSem (th->cancel_event);
DosCloseEventSem (th->done_event );
free (th);
}
}
示例3: decoder_init
int _System decoder_init( void **ppvPluginWork )
{
PLUGINWORK *pPluginWork;
pPluginWork = (void *)malloc( sizeof( PLUGINWORK ) );
if(pPluginWork == 0) {
*ppvPluginWork = 0;
return -1;
}
memset( pPluginWork, 0, sizeof( PLUGINWORK ) );
DosCreateEventSem( NULL, &pPluginWork->hevThreadTrigger, 0UL, FALSE );
DosCreateEventSem( NULL, &pPluginWork->hevThreadA, 0UL, FALSE );
pPluginWork->tidThreadDecode = _beginthread( ThreadDecodeMain, NULL, 1024 * 1024, pPluginWork );
if(pPluginWork->tidThreadDecode == -1) {
/* can't create thread */
DosCloseEventSem( pPluginWork->hevThreadTrigger ); pPluginWork->hevThreadTrigger = NULLHANDLE;
DosCloseEventSem( pPluginWork->hevThreadA ); pPluginWork->hevThreadA = NULLHANDLE;
free( pPluginWork ); pPluginWork = NULL;
*ppvPluginWork = 0;
return -1;
}
*ppvPluginWork = (void *)pPluginWork;
pPluginWork->songlength = 0xffffffffUL;
pPluginWork->fStop = FALSE;
pPluginWork->fTerminate = FALSE;
// DosSetPriority( PRTYS_THREAD, PRTYC_TIMECRITICAL, PRTYD_MAXIMUM, pPluginWork->tidThreadDecode );
return 0;
}
示例4: 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;
}
示例5: _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;
}
示例6: strdup
int GUI::OpenPipe(char *Command, EModel *notify) {
int i;
for (i = 0; i < MAX_PIPES; i++) {
if (Pipes[i].used == 0) {
Pipes[i].reading = 1;
Pipes[i].stopped = 1;
Pipes[i].id = i;
Pipes[i].bufused = 0;
Pipes[i].bufpos = 0;
Pipes[i].buflen = PIPE_BUFLEN;
Pipes[i].Command = strdup(Command);
Pipes[i].notify = notify;
Pipes[i].DoTerm = 0;
if ((Pipes[i].buffer = (char *)malloc(PIPE_BUFLEN)) == 0) {
free(Pipes[i].Command);
return -1;
}
if (0 != DosCreateMutexSem(0, &Pipes[i].Access, 0, 0)) {
free(Pipes[i].Command);
free(Pipes[i].buffer);
return -1;
}
if (0 != DosCreateEventSem(0, &Pipes[i].ResumeRead, 0, 0)) {
free(Pipes[i].Command);
free(Pipes[i].buffer);
DosCloseMutexSem(Pipes[i].Access);
return -1;
}
if (0 != DosCreateEventSem(0, &Pipes[i].NewData, 0, 0)) {
free(Pipes[i].Command);
free(Pipes[i].buffer);
DosCloseEventSem(Pipes[i].ResumeRead);
DosCloseMutexSem(Pipes[i].Access);
return -1;
}
#if defined(__WATCOMC__) || defined(__MT__) || defined(__MULTI__)
Pipes[i].tid = _beginthread(PipeThread,
FAKE_BEGINTHREAD_NULL
16384, &Pipes[i]);
#else // if defined(__WATCOMC__) || defined(__MT__) || defined(__MULTI__)
DosCreateThread(Pipes[i].tid,
(PFNTHREAD)PipeThread,
&Pipes[i],
0, /* immediate */
16384);
#endif // if defined(__WATCOMC__) || defined(__MT__) || defined(__MULTI__)
Pipes[i].used = 1;
// fprintf(stderr, "Pipe Open: %d\n", i);
return i;
}
}
return -1;
}
示例7: __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 );
}
示例8: DART_CloseAudio
void DART_CloseAudio(_THIS)
{
MCI_GENERIC_PARMS GenericParms;
int rc;
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_STOP, MCI_WAIT, &GenericParms, 0);
if (rc!=MCIERR_SUCCESS)
{
#ifdef SFX_DEBUG_BUILD
printf("Could not stop DART playback!\n");
fflush(stdout);
#endif
}
DosCloseEventSem(_this->hidden->hevAudioBufferPlayed);
{
int i;
for (i=0; i<_this->hidden->iCurrNumBufs; i++) SDL_free((void *)(_this->hidden->pMixBuffers[i].ulUserParm));
}
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_BUFFER, MCI_WAIT | MCI_DEALLOCATE_MEMORY, &(_this->hidden->BufferParms), 0);
SDL_free(_this->hidden->pMixBuffers); _this->hidden->pMixBuffers = NULL;
rc = mciSendCommand(_this->hidden->iCurrDeviceOrd, MCI_CLOSE, MCI_WAIT, &(GenericParms), 0);
}
示例9: SignalUserEvent
/****************************************************************\
* Routine to signal consumer to release resource. *
*--------------------------------------------------------------*
* *
* Name: SignalUserEvent(pfAutoMode) *
* *
* Purpose: Posts user event semaphore to signal thread to *
* release resource. Also posts event to stop *
* Auto mode if *pfAutoMode is true. *
* *
* Usage: Called in file usercmd.c when the user selects *
* Event from the semaphore menu. *
* *
* Method: Turns off Auto mode, if present by posting auto *
* semaphore. User event is then posted. *
* *
* Returns: *
* *
\****************************************************************/
VOID SignalUserEvent(PULONG pfAutoMode)
{
ULONG rc;
/* If sample is in auto mode turn auto mode off. */
if (*pfAutoMode)
{
rc = DosPostEventSem(hevStopAuto);
if (rc)
{
SemError("DosPostEventSem Stop Auto",rc);
}
/* Wait for auto mode thread to die, so we don't
end up with multiple copies of it later. */
rc = DosWaitThread(&tidAutoThread,0L);
if (rc)
{
SemError("DosWaitThread",rc);
}
*pfAutoMode = FALSE;
DosCloseEventSem (hevStopAuto);
}
/* If Auto mode haas already posted the event this is OK
so we will not check error codes here. */
DosPostEventSem(aSquares[rand() % MAXRESOURCES].hev);
return;
}
示例10: _PR_MD_DESTROY_SEM
void
_PR_MD_DESTROY_SEM(_MDSemaphore *md)
{
int rv;
rv = DosCloseEventSem(md->sem);
PR_ASSERT(rv == NO_ERROR);
}
示例11: avcodec_thread_free
/**
* free what has been allocated by avcodec_thread_init().
* must be called after decoding has finished, especially do not call while avcodec_thread_execute() is running
*/
void avcodec_thread_free(AVCodecContext *s){
ThreadContext *c= s->thread_opaque;
int i;
for(i=0; i<s->thread_count; i++){
c[i].func= NULL;
DosPostEventSem(c[i].work_sem);
// ReleaseSemaphore(c[i].work_sem, 1, 0);
DosWaitThread((PTID)&c[i].thread,DCWW_WAIT);
// WaitForSingleObject(c[i].thread, INFINITE);
if(c[i].work_sem) DosCloseEventSem(c[i].work_sem);//CloseHandle(c[i].work_sem);
if(c[i].done_sem) DosCloseEventSem(c[i].done_sem);//CloseHandle(c[i].done_sem);
}
av_freep(&s->thread_opaque);
}
示例12: DosCloseEventSem
//***************************************************************************
//* *
//* BOOL closeSemaphore() *
//* *
//* Closes the Event Semaphore *
//* Returns: *
//* TRUE - Success *
//* FALSE - Unsuccessful closing of event semaphore *
//* *
//* Preconditions: init_Semaphore has to be called successfully before *
//* *
//***************************************************************************
BOOL scsiObj::closeSemaphore()
{
ULONG rc; // return value
rc = DosCloseEventSem(postSema); // close event semaphore
if (rc) return FALSE; // DosCloseEventSem failed
return TRUE;
}
示例13: Os2_delete_async_info
/* delete_async_info deletes the structure created by create_async_info and
* all of its components.
*/
static void Os2_delete_async_info(void *async_info)
{
AsyncInfo *ai = async_info;
if (ai == NULL)
return;
DosCloseEventSem(ai->sem);
Free_TSD(ai->TSD, ai);
}
示例14: DosCloseEventSem
omni_semaphore::~omni_semaphore(void)
{
APIRET rc = DosCloseEventSem( nt_sem );
if (rc!=0) {
DB( cerr << "omni_semaphore::~omni_semaphore: DosCloseEventSem error "
<< rc << endl );
throw omni_thread_fatal(rc);
}
}
示例15: vlc_join
void vlc_join (vlc_thread_t th, void **result)
{
ULONG rc;
do
{
vlc_testcancel();
rc = vlc_WaitForSingleObject( th->done_event, SEM_INDEFINITE_WAIT );
} while( rc == ERROR_INTERRUPT );
if (result != NULL)
*result = th->data;
DosCloseEventSem( th->cancel_event );
DosCloseEventSem( th->done_event );
free( th );
}