Buckets:
MisterAI/LocalAI_Demo_backends / cpu-diffusers.upgrade-tmp /venv /lib /python3.10 /site-packages /zmq /utils /mutex.h
| /* | |
| * simplified from mutex.c from Foundation Library, in the Public Domain | |
| * https://github.com/rampantpixels/foundation_lib/blob/master/foundation/mutex.c | |
| * | |
| * This file is Copyright (C) PyZMQ Developers | |
| * Distributed under the terms of the Modified BSD License. | |
| * | |
| */ | |
| typedef struct { | |
| CRITICAL_SECTION csection; | |
| pthread_mutex_t mutex; | |
| } mutex_t; | |
| static void | |
| _mutex_initialize(mutex_t* mutex) { | |
| InitializeCriticalSectionAndSpinCount(&mutex->csection, 4000); | |
| pthread_mutexattr_t attr; | |
| pthread_mutexattr_init(&attr); | |
| pthread_mutexattr_settype(&attr, PTHREAD_MUTEX_RECURSIVE); | |
| pthread_mutex_init(&mutex->mutex, &attr); | |
| pthread_mutexattr_destroy(&attr); | |
| } | |
| static void | |
| _mutex_finalize(mutex_t* mutex) { | |
| DeleteCriticalSection(&mutex->csection); | |
| pthread_mutex_destroy(&mutex->mutex); | |
| } | |
| mutex_t* | |
| mutex_allocate(void) { | |
| mutex_t* mutex = (mutex_t*)malloc(sizeof(mutex_t)); | |
| _mutex_initialize(mutex); | |
| return mutex; | |
| } | |
| void | |
| mutex_deallocate(mutex_t* mutex) { | |
| if (!mutex) | |
| return; | |
| _mutex_finalize(mutex); | |
| free(mutex); | |
| } | |
| int | |
| mutex_lock(mutex_t* mutex) { | |
| EnterCriticalSection(&mutex->csection); | |
| return 0; | |
| return pthread_mutex_lock(&mutex->mutex); | |
| } | |
| int | |
| mutex_unlock(mutex_t* mutex) { | |
| LeaveCriticalSection(&mutex->csection); | |
| return 0; | |
| return pthread_mutex_unlock(&mutex->mutex); | |
| } | |
Xet Storage Details
- Size:
- 1.65 kB
- Xet hash:
- 28437fd6940e8e5135e8bf6516b4b215cf9d1c526e75fcacf99a486d5749a2e4
·
Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.