12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- #include "ceres/thread_token_provider.h"
- namespace ceres::internal {
- ThreadTokenProvider::ThreadTokenProvider(int num_threads) {
- for (int i = 0; i < num_threads; i++) {
- pool_.Push(i);
- }
- }
- int ThreadTokenProvider::Acquire() {
- int thread_id;
- CHECK(pool_.Wait(&thread_id));
- return thread_id;
- }
- void ThreadTokenProvider::Release(int thread_id) { pool_.Push(thread_id); }
- }
|