| 35 | Recycle::~Recycle() {} |
| 36 | |
| 37 | int Recycle::init() { |
| 38 | // init mutex lock; |
| 39 | if (pthread_mutex_init(&_recycle_mutex, NULL) != 0) { |
| 40 | LOG(ERROR) << "init recycle lock failed"; |
| 41 | return -1; |
| 42 | } |
| 43 | |
| 44 | _running = true; |
| 45 | |
| 46 | // init thread; |
| 47 | if (pthread_create(&_recycle_thread, |
| 48 | NULL, |
| 49 | Recycle::recycle_func, |
| 50 | reinterpret_cast<void*>(this)) != 0) { |
| 51 | LOG(ERROR) << "init recycle thread failed"; |
| 52 | return -1; |
| 53 | } |
| 54 | return 0; |
| 55 | } |
| 56 | |
| 57 | int Recycle::destroy() { |
| 58 | _running = false; |