| 404 | |
| 405 | |
| 406 | void* read_thread(void* arg) { |
| 407 | const size_t N = 10000; |
| 408 | #ifdef CHECK_RWLOCK |
| 409 | pthread_rwlock_t* lock = (pthread_rwlock_t*)arg; |
| 410 | #else |
| 411 | pthread_mutex_t* lock = (pthread_mutex_t*)arg; |
| 412 | #endif |
| 413 | const long t1 = butil::cpuwide_time_ns(); |
| 414 | for (size_t i = 0; i < N; ++i) { |
| 415 | #ifdef CHECK_RWLOCK |
| 416 | pthread_rwlock_rdlock(lock); |
| 417 | pthread_rwlock_unlock(lock); |
| 418 | #else |
| 419 | pthread_mutex_lock(lock); |
| 420 | pthread_mutex_unlock(lock); |
| 421 | #endif |
| 422 | } |
| 423 | const long t2 = butil::cpuwide_time_ns(); |
| 424 | return new long((t2 - t1)/N); |
| 425 | } |
| 426 | |
| 427 | void* write_thread(void*) { |
| 428 | return NULL; |
nothing calls this directly
no test coverage detected