Skip to content

Commit 014c59a

Browse files
authored
Improve SCOPE_MAKESURE_YIELD macro (alibaba#1110)
1 parent 25deb99 commit 014c59a

1 file changed

Lines changed: 4 additions & 4 deletions

File tree

thread/thread.h

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -599,7 +599,7 @@ namespace photon
599599
*/
600600
#define WITH_LOCK(mutex) if (auto __lock__ = scoped_lock(mutex))
601601

602-
#define SCOPE_MAKESURE_YIELD \
603-
uint64_t __swc_##__LINE__ = get_vcpu(photon::CURRENT)->switch_count; \
604-
DEFER(if (__swc_##__LINE__ == get_vcpu(photon::CURRENT)->switch_count) \
605-
photon::thread_yield(););
602+
#define SCOPE_MAKESURE_YIELD \
603+
uint64_t _CONCAT(__swc__, __LINE__) = get_vcpu(photon::CURRENT)->switch_count; \
604+
DEFER(({if (_CONCAT(__swc__, __LINE__) == get_vcpu(photon::CURRENT)->switch_count) \
605+
photon::thread_yield();}))

0 commit comments

Comments
 (0)