diff options
| author | 2025-09-15 19:40:06 -0500 | |
|---|---|---|
| committer | 2025-09-15 19:40:06 -0500 | |
| commit | 624afe1336a754d1237b60bb25a6f15818db360f (patch) | |
| tree | b7421332e7044283d76ac4de958046fb31b77109 | |
| parent | Fix #1643, but add features.h (diff) | |
Test replacing CRITICAL_SECTION with SRWLOCK.no-critical-section
We use rw locks anyway, and it should be faster and smaller.
| -rw-r--r-- | src/core/abstract.c | 12 | ||||
| -rw-r--r-- | src/core/ev.c | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/src/core/abstract.c b/src/core/abstract.c index 44f98b60..4cd7673f 100644 --- a/src/core/abstract.c +++ b/src/core/abstract.c @@ -88,7 +88,7 @@ void *janet_abstract_threaded(const JanetAbstractType *atype, size_t size) { #ifdef JANET_WINDOWS size_t janet_os_mutex_size(void) { - return sizeof(CRITICAL_SECTION); + return sizeof(SRWLOCK); } size_t janet_os_rwlock_size(void) { @@ -96,20 +96,20 @@ size_t janet_os_rwlock_size(void) { } void janet_os_mutex_init(JanetOSMutex *mutex) { - InitializeCriticalSection((CRITICAL_SECTION *) mutex); + InitializeSRWLock((PSRWLOCK) mutex); } void janet_os_mutex_deinit(JanetOSMutex *mutex) { - DeleteCriticalSection((CRITICAL_SECTION *) mutex); + /* no op? */ + (void) mutex; } void janet_os_mutex_lock(JanetOSMutex *mutex) { - EnterCriticalSection((CRITICAL_SECTION *) mutex); + AcquireSRWLockExclusive((PSRWLOCK) mutex); } void janet_os_mutex_unlock(JanetOSMutex *mutex) { - /* error handling? May want to keep counter */ - LeaveCriticalSection((CRITICAL_SECTION *) mutex); + ReleaseSRWLockExclusive((PSRWLOCK) mutex); } void janet_os_rwlock_init(JanetOSRWLock *rwlock) { diff --git a/src/core/ev.c b/src/core/ev.c index 3acf9dd6..d2d31277 100644 --- a/src/core/ev.c +++ b/src/core/ev.c @@ -83,7 +83,7 @@ struct JanetChannel { int closed; int is_threaded; #ifdef JANET_WINDOWS - CRITICAL_SECTION lock; + SRWLOCK lock; #else pthread_mutex_t lock; #endif |
