MCPcopy Create free account
hub / github.com/alibaba/PhotonLibOS / rwlocktest

Function rwlocktest

thread/test/test.cpp:759–779  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

757thread_local photon::rwlock rwl;
758
759void *rwlocktest(void* args) {
760 uint64_t carg = (uint64_t) args;
761 auto mode = carg & ((1ULL<<32) -1);
762 auto id = carg >> 32;
763 // LOG_DEBUG("locking ", VALUE(id), VALUE(mode));
764 rwl.lock(mode);
765 LOG_DEBUG("locked ", VALUE(id), VALUE(mode));
766 EXPECT_EQ(id, rw_count);
767 rw_count ++;
768 if (mode == photon::RLOCK)
769 EXPECT_FALSE(writing);
770 else
771 writing = true;
772 photon::thread_usleep(100*1000);
773 if (mode == photon::WLOCK)
774 writing = false;
775 LOG_DEBUG("unlocking ", VALUE(id), VALUE(mode));
776 rwl.unlock();
777 // LOG_DEBUG("unlocked ", VALUE(id), VALUE(mode));
778 return NULL;
779}
780
781TEST(RWLock, checklock) {
782 std::vector<photon::join_handle*> handles;

Callers

nothing calls this directly

Calls 3

thread_usleepFunction · 0.50
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected