Exemplo n.º 1
0
FskErr FskMutexNew_uninstrumented(FskMutex *mutex, const char *name)
{
	FskErr err;
	pthread_mutexattr_t   attr;
	err = FskMemPtrNewClear_Untracked(sizeof(FskMutexRecord), (FskMemPtr *)mutex);
	BAIL_IF_ERR(err);

	if ((pthread_mutexattr_init(&attr) != 0) ||
		(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) ||
		(pthread_mutex_init(&(*mutex)->mutex, &attr) != 0)) {
		BAIL(kFskErrOperationFailed);
	}

#if SUPPORT_INSTRUMENTATION
	(*mutex)->name = FskStrDoCopy_Untracked(name);
#endif

bail:
	pthread_mutexattr_destroy(&attr);

	if ((err != kFskErrNone) && (*mutex != NULL)) {
#if SUPPORT_INSTRUMENTATION
		FskMemPtrDispose_Untracked((FskMemPtr)(*mutex)->name);
#endif
		FskMemPtrDispose_Untracked(*mutex);
		*mutex = NULL;
	}

	return err;
}
Exemplo n.º 2
0
FskErr FskMutexDispose_uninstrumented(FskMutex mutex)
{
	if (mutex) {
		pthread_mutex_destroy(&mutex->mutex);
#if SUPPORT_INSTRUMENTATION
		FskMemPtrDispose_Untracked((FskMemPtr)mutex->name);
#endif
		FskMemPtrDispose_Untracked(mutex);
	}

	return kFskErrNone;
}
Exemplo n.º 3
0
FskErr FskAudioDecompressDispose(FskAudioDecompress deco)
{
    if (deco) {
        if (deco->decoder && deco->decoder->doDispose)
            deco->decoder->doDispose(deco->state, deco);
        FskMemPtrDispose((void *)deco->formatInfo);
#if SUPPORT_INSTRUMENTATION
        FskInstrumentedItemDispose(deco);
        FskMemPtrDispose_Untracked((char *)deco->_instrumented.name);
#endif
        FskMemPtrDispose(deco);
    }
    return kFskErrNone;
}
Exemplo n.º 4
0
FskErr FskMutexNew_(FskMutex *mutex, const char *name, FSK_SYNCHRONIZATION_DEBUG_ARGS)
#endif
{
	FskMutex mtx = NULL;
	FskErr err;

	err = FskMemPtrNewClear(sizeof(FskMutexRecord), (FskMemPtr *)&mtx);
	BAIL_IF_ERR(err);

	err = KplMutexNew((KplMutex*)&mtx->kplMutex);
	BAIL_IF_ERR(err);

#if SUPPORT_INSTRUMENTATION
	mtx->name = FskStrDoCopy_Untracked(name);
	FskInstrumentedItemNew(mtx, mtx->name, &gFskMutexTypeInstrumentation);

#if SUPPORT_SYNCHRONIZATION_DEBUG
	if (FskInstrumentedItemHasListeners(mtx)) {
		FskSynchronizationInstrMsgRecord msg;
		msg.name = name;
		msg.file = file;
		msg.line = line;
		msg.function = function;
		FskInstrumentedItemSendMessage(mtx, kFskSynchronizationInstrMsgMutexNew, &msg);
	}
#endif
#endif

bail:
	if ((err != kFskErrNone) && (mtx != NULL)) {
		KplMutexDispose(mtx->kplMutex);

#if SUPPORT_INSTRUMENTATION
		FskMemPtrDispose_Untracked((void*)mtx->name);
#endif
		FskMemPtrDispose(mtx);
		mtx = NULL;
	}

	*mutex = mtx;

	return err;
}
Exemplo n.º 5
0
FskErr FskMutexNew_(FskMutex *mutex, const char *name, FSK_SYNCHRONIZATION_DEBUG_ARGS)
#endif
{
	FskErr err;
	pthread_mutexattr_t   attr;
	err = FskMemPtrNewClear(sizeof(FskMutexRecord), (FskMemPtr *)mutex);
	BAIL_IF_ERR(err);

	if ((pthread_mutexattr_init(&attr) != 0) ||
		(pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE) != 0) ||
		(pthread_mutex_init(&(*mutex)->mutex, &attr) != 0)) {
		BAIL(kFskErrOperationFailed);
	}

#if SUPPORT_INSTRUMENTATION
	(*mutex)->name = FskStrDoCopy_Untracked(name);
	FskInstrumentedItemNew(*mutex, (*mutex)->name, &gFskMutexTypeInstrumentation);

#if SUPPORT_SYNCHRONIZATION_DEBUG
	if (FskInstrumentedItemHasListeners(*mutex)) {
		FskSynchronizationInstrMsgRecord msg;
		msg.name = name;
		msg.file = file;
		msg.line = line;
		msg.function = function;
		FskInstrumentedItemSendMessage(*mutex, kFskSynchronizationInstrMsgMutexNew, &msg);
	}
#endif
#endif

bail:
	pthread_mutexattr_destroy(&attr);

	if ((err != kFskErrNone) && (*mutex != NULL)) {
#if SUPPORT_INSTRUMENTATION
		FskMemPtrDispose_Untracked((FskMemPtr)(*mutex)->name);
#endif
		FskMemPtrDispose(*mutex);
		*mutex = NULL;
	}

	return err;
}
Exemplo n.º 6
0
FskErr FskMutexNew_(FskMutex *mutex, const char *name, FSK_SYNCHRONIZATION_DEBUG_ARGS)
#endif
{
	FskErr err;

	err = FskMemPtrNewClear(sizeof(FskMutexRecord), (FskMemPtr *)mutex);
	BAIL_IF_ERR(err);

	InitializeCriticalSection(&(*mutex)->cs);

#if SUPPORT_INSTRUMENTATION
	(*mutex)->name = FskStrDoCopy_Untracked(name);
	FskInstrumentedItemNew(*mutex, (*mutex)->name, &gFskMutexTypeInstrumentation);

#if SUPPORT_SYNCHRONIZATION_DEBUG
	if (FskInstrumentedItemHasListeners(*mutex)) {
		FskSynchronizationInstrMsgRecord msg;
		msg.name = name;
		msg.file = file;
		msg.line = line;
		msg.function = function;
		FskInstrumentedItemSendMessage(*mutex, kFskSynchronizationInstrMsgMutexNew, &msg);
	}
#endif
#endif

bail:
	if ((err != kFskErrNone) && (*mutex != NULL)) {
#if SUPPORT_INSTRUMENTATION
		FskMemPtrDispose_Untracked((*mutex)->name);
#endif
		FskMemPtrDispose(*mutex);
		*mutex = NULL;
	}

	return err;
}
Exemplo n.º 7
0
FskErr FskMutexDispose_(FskMutex mutex, FSK_SYNCHRONIZATION_DEBUG_ARGS)
#endif
{
	if (mutex) {
#if SUPPORT_INSTRUMENTATION && SUPPORT_SYNCHRONIZATION_DEBUG
		if (FskInstrumentedItemHasListeners(mutex)) {
			FskSynchronizationInstrMsgRecord msg;
			msg.name = mutex->name;
			msg.file = file;
			msg.line = line;
			msg.function = function;
			FskInstrumentedItemSendMessage(mutex, kFskSynchronizationInstrMsgMutexDispose, &msg);
		}
#endif
		KplMutexDispose(mutex->kplMutex);
		FskInstrumentedItemDispose(mutex);
#if SUPPORT_INSTRUMENTATION
		FskMemPtrDispose_Untracked((void*)mutex->name);
#endif
		FskMemPtrDispose(mutex);
	}

	return kFskErrNone;
}