LIU Hao wrote:

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

Sure, I don't mind changing the name. I wasn't sure what naming convention to 
stick to, so I chose one similar to one I use in my posix32 library.

> 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));
>
>    ```

I just learnt something new! That's a very clever approach. I'll send updated 
version.

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

I mentioned that I want to add support for POSIX robust mutexes next, and this 
would require adding `pthread_mutexattr_{set,get}robust`. As a preparation 
step, I want to update `pthread_mutexattr_*` functions and add tests for each 
of them.

However, if you insist on keeping tests for `pthread_mutexattr_gettype` for 
now, I can change 0019.txt, 0020.txt and 0021.txt to preserve it. What you say?

> 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.

Yeah, I had mixing feeling about this. Will it be ok to loop with 
`InterlockedExchange` in main until thread sets a variable? I hesitate to use 
`pthread_barrier_t` because its implementation uses `pthread_mutex_t`, so it 
would be a bit awkward.

- Kirill Makurin

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

Reply via email to