9 * Create a static instance at the file level to get callbacks called when the
10 * process exits via main() or exit().
15 typedef void (*callback_t)(void *arg);
18 int ret = pthread_mutex_init(&lock_, NULL);
23 pthread_mutex_lock(&lock_);
24 std::vector<struct cb>::iterator it;
25 for (it = funcs_.begin(); it != funcs_.end(); it++) {
29 pthread_mutex_unlock(&lock_);
32 void add_callback(callback_t func, void *arg) {
33 pthread_mutex_lock(&lock_);
34 struct cb callback = { func, arg };
35 funcs_.push_back(callback);
36 pthread_mutex_unlock(&lock_);
45 std::vector<struct cb> funcs_;
46 pthread_mutex_t lock_;