+
+/* Dynamically allocated thread-specific data with lots of slots.
+ *
+ * pthread_key_t can provide as few as 128 pieces of thread-specific data (even
+ * glibc is limited to 1,024). Thus, one must be careful to allocate only a
+ * few keys globally. One cannot, for example, allocate a key for every
+ * instance of a data structure if there might be an arbitrary number of those
+ * data structures.
+ *
+ * This API is similar to the pthread one (simply search and replace pthread_
+ * by ovsthread_) but it a much larger limit that can be raised if necessary
+ * (by recompiling). Thus, one may more freely use this form of
+ * thread-specific data.
+ *
+ * ovsthread_key_t also differs from pthread_key_t in the following ways:
+ *
+ * - Destructors must not access thread-specific data (via ovsthread_key).
+ *
+ * - The pthread_key_t API allows concurrently exiting threads to start
+ * executing the destructor after pthread_key_delete() returns. The
+ * ovsthread_key_t API guarantees that, when ovsthread_key_delete()
+ * returns, all destructors have returned and no new ones will start
+ * execution.
+ */
+typedef struct ovsthread_key *ovsthread_key_t;
+
+void ovsthread_key_create(ovsthread_key_t *, void (*destructor)(void *));
+void ovsthread_key_delete(ovsthread_key_t);
+
+void ovsthread_setspecific(ovsthread_key_t, const void *);
+void *ovsthread_getspecific(ovsthread_key_t);