Lines Matching defs:key

184 Per-thread data ("key") support.

186 Use PyThread_create_key() to create a new key. This is typically shared
219 /* A singly-linked list of struct key objects remembers all the key->value
223 struct key {
225 struct key *next;
230 /* The key and its associated value. */
231 int key;
235 static struct key *keyhead = NULL;
240 * If the current thread has a mapping for key, the appropriate struct key*
242 * If there is no mapping for key in the current thread, then:
244 * Else a mapping of key to value is created for the current thread,
245 * and a pointer to a new struct key* is returned; except that if
246 * malloc() can't find room for a new struct key*, NULL is returned.
253 * another thread to mutate the list, via key deletion, concurrent with
257 * That could lead to anything, from failing to find a key that exists, to
260 static struct key *
261 find_key(int key, void *value)
263 struct key *p, *prev_p;
271 if (p->id == id && p->key == key)
287 p = (struct key *)malloc(sizeof(struct key));
290 p->key = key;
300 /* Return a new key. This must be called before any other functions in
315 /* Forget the associations for key across *all* threads. */
317 PyThread_delete_key(int key)
319 struct key *p, **q;
324 if (p->key == key) {
335 /* Confusing: If the current thread has an association for key,
337 * an association of key to value for the current thread. 0 is returned
342 PyThread_set_key_value(int key, void *value)
344 struct key *p;
347 p = find_key(key, value);
354 /* Retrieve the value associated with key in the current thread, or NULL
355 * if the current thread doesn't have an association for key.
358 PyThread_get_key_value(int key)
360 struct key *p = find_key(key, NULL);
368 /* Forget the current thread's association for key, if any. */
370 PyThread_delete_key_value(int key)
373 struct key *p, **q;
378 if (p->key == key && p->id == id) {
399 struct key *p, **q;