在 2026-9-6 21:27, Kirill Makurin 写道:
Hello,

This is updated version of the mutex changes.
GitHub CI run: https://github.com/maiddaisuki/mingw-w64/actions/runs/34029615558 <https://github.com/ maiddaisuki/mingw-w64/actions/runs/34029615558>

The changes are:

- patch "winpthreads: mutex.c: simplify `pthread_mutex_*lock` functions'" was 
dropped
- patch "winpthreads: mutex.c: improve `pthread_mutex_destroy`" was updated
- patch "winpthreads: mutex.c: refactor implementation" was updated

0010:

If I understand correctly, `WinpthreadsMutexImpl` is a vtable, so maybe `WinpthreadsMutexVtable` is a better name? `xxImpl` reminds me about a derived class.

And the union of pointers in `WinpthreadsMutex` makes less sense now; the overhead and complexity of an extra allocation may cancel any benefits of a union. How about

   ```
   struct WinpthreadsMutex {
     const WinpthreadsMutexVtable *Vtable;
     union {
       WinpthreadsNormalMutex Normal;
       WinpthreadsErrorCheckMutex ErrorCheck;
       WinpthreadsRecursiveMutex Recursive;
     } Mutex;
   };

   // ...
   WinpthreadsRecursiveMutex *mutex = malloc (
       RTL_SIZEOF_THROUGH_FIELD (WinpthreadsRecursiveMutex, Recursive));

   ```

---

0019, 0020, 0021 delete tests for `pthread_mutexattr_gettype()`.

---

0023 has this:

   assert(pthread_create(&thread, NULL, ThreadA, &mutex) == 0);
   Sleep(100);
   /**
    * Ensure we do not dead lock if thread did not lock mutex fast enough.
    */
   assert(pthread_mutex_trylock(&mutex) == EBUSY);

I think this is a bit fragile; you can use a barrier here.


--
Best regards,
LIU Hao

Attachment: OpenPGP_signature.asc
Description: OpenPGP digital signature

_______________________________________________
Mingw-w64-public mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/mingw-w64-public

Reply via email to