Probably unnecessary InterlockedCompareExchangePointer in List_remove in thread.h
Vaclav Haisman
V.Haisman@sh.cvut.cz
Sun May 29 15:03:00 GMT 2005
I think that the call to InterlockedCompareExchangePointer() can and should be
replaced by ordinary if and assignment. The synchronization it provides doesn't
seem to be necessary.
VH.
2005-05-29 Vaclav Haisman <v.haisman@sh.cvut.cz>
* thread.h (List_remove): Make node parameter const. Don't use
InterlockedCompareExchangePointer.
-------------- next part --------------
Index: thread.h
===================================================================
RCS file: /cvs/src/src/winsup/cygwin/thread.h,v
retrieving revision 1.92
diff -c -p -d -r1.92 thread.h
*** thread.h 28 May 2004 19:50:07 -0000 1.92
--- thread.h 29 May 2005 14:46:08 -0000
*************** List_insert (list_node *&head, list_node
*** 136,149 ****
}
template <class list_node> inline void
! List_remove (fast_mutex &mx, list_node *&head, list_node *node)
{
if (!node)
return;
mx.lock ();
if (head)
{
! if (InterlockedCompareExchangePointer (&head, node->next, node) != node)
{
list_node *cur = head;
--- 136,151 ----
}
template <class list_node> inline void
! List_remove (fast_mutex &mx, list_node *&head, list_node const *node)
{
if (!node)
return;
mx.lock ();
if (head)
{
! if (head == node)
! head = head->next;
! else
{
list_node *cur = head;
More information about the Cygwin-patches
mailing list