Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / native_client_sdk / src / libraries / third_party / pthreads-win32 / ptw32_tkAssocDestroy.c
blobfedebf593575558bb3d70a2250fdf6a5c6ff4a24
1 /*
2 * ptw32_tkAssocDestroy.c
4 * Description:
5 * This translation unit implements routines which are private to
6 * the implementation and may be used throughout it.
8 * --------------------------------------------------------------------------
10 * Pthreads-win32 - POSIX Threads Library for Win32
11 * Copyright(C) 1998 John E. Bossom
12 * Copyright(C) 1999,2005 Pthreads-win32 contributors
14 * Contact Email: rpj@callisto.canberra.edu.au
16 * The current list of contributors is contained
17 * in the file CONTRIBUTORS included with the source
18 * code distribution. The list can also be seen at the
19 * following World Wide Web location:
20 * http://sources.redhat.com/pthreads-win32/contributors.html
22 * This library is free software; you can redistribute it and/or
23 * modify it under the terms of the GNU Lesser General Public
24 * License as published by the Free Software Foundation; either
25 * version 2 of the License, or (at your option) any later version.
27 * This library is distributed in the hope that it will be useful,
28 * but WITHOUT ANY WARRANTY; without even the implied warranty of
29 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
30 * Lesser General Public License for more details.
32 * You should have received a copy of the GNU Lesser General Public
33 * License along with this library in the file COPYING.LIB;
34 * if not, write to the Free Software Foundation, Inc.,
35 * 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA
38 #include "pthread.h"
39 #include "implement.h"
42 void
43 ptw32_tkAssocDestroy (ThreadKeyAssoc * assoc)
45 * -------------------------------------------------------------------
46 * This routine releases all resources for the given ThreadKeyAssoc
47 * once it is no longer being referenced
48 * ie) either the key or thread has stopped referencing it.
50 * Parameters:
51 * assoc
52 * an instance of ThreadKeyAssoc.
53 * Returns:
54 * N/A
55 * -------------------------------------------------------------------
60 * Both key->keyLock and thread->threadLock are locked before
61 * entry to this routine.
63 if (assoc != NULL)
65 ThreadKeyAssoc * prev, * next;
67 /* Remove assoc from thread's keys chain */
68 prev = assoc->prevKey;
69 next = assoc->nextKey;
70 if (prev != NULL)
72 prev->nextKey = next;
74 if (next != NULL)
76 next->prevKey = prev;
79 if (assoc->thread->keys == assoc)
81 /* We're at the head of the thread's keys chain */
82 assoc->thread->keys = next;
84 if (assoc->thread->nextAssoc == assoc)
87 * Thread is exiting and we're deleting the assoc to be processed next.
88 * Hand thread the assoc after this one.
90 assoc->thread->nextAssoc = next;
93 /* Remove assoc from key's threads chain */
94 prev = assoc->prevThread;
95 next = assoc->nextThread;
96 if (prev != NULL)
98 prev->nextThread = next;
100 if (next != NULL)
102 next->prevThread = prev;
105 if (assoc->key->threads == assoc)
107 /* We're at the head of the key's threads chain */
108 assoc->key->threads = next;
111 free (assoc);
114 } /* ptw32_tkAssocDestroy */