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

Function smprwlocktest

thread/test/test.cpp:1044–1064  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1042photon::rwlock srwl;
1043
1044void *smprwlocktest(void* args) {
1045 uint64_t carg = (uint64_t) args;
1046 auto mode = carg & ((1ULL<<32) -1);
1047 auto id = carg >> 32;
1048 // LOG_DEBUG("locking ", VALUE(id), VALUE(mode));
1049 srwl.lock(mode);
1050 LOG_DEBUG("locked ", VALUE(id), VALUE(mode));
1051 srw_count ++;
1052 if (mode == photon::RLOCK)
1053 EXPECT_FALSE(swriting);
1054 else {
1055 swriting = true;
1056 }
1057 photon::thread_usleep(1000);
1058 if (mode == photon::WLOCK)
1059 swriting = false;
1060 LOG_DEBUG("unlocking ", VALUE(id), VALUE(mode));
1061 srwl.unlock();
1062 // LOG_DEBUG("unlocked ", VALUE(id), VALUE(mode));
1063 return NULL;
1064}
1065
1066TEST(smp, rwlock) {
1067 srw_count = 0;

Callers

nothing calls this directly

Calls 3

thread_usleepFunction · 0.50
lockMethod · 0.45
unlockMethod · 0.45

Tested by

no test coverage detected