You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Jun 11, 2020. It is now read-only.
Repository navigation
This repository was archived by the owner on Jun 11, 2020. It is now read-only.
Can you please explain that why it needs "__sync_synchronize()" in the source code? #1
As I see, there are two ways of using "__sync_synchronize" thi the cstring project.
First, used at the beginning of grab/release api function;
Second, used after calling cstring_clone.
I can't figure out why cstring need this memory barrier here.
I think here's not the situation '__sync_synchronize' needed. No memory ordering need to be guaranteed because you have used lock during interning cstring, which is the only share data in multithread. No where else can change s->type.
Anyway it affects little, removing it perhaps improve performance a little.
Activity
cloudwu commentedon Sep 24, 2013
I guess memory barrier between cstring s and s->type is needed. maybe it's unusefu. Should I remove then?
wilsonwen commentedon Sep 24, 2013
I think here's not the situation '__sync_synchronize' needed. No memory ordering need to be guaranteed because you have used lock during interning cstring, which is the only share data in multithread. No where else can change s->type.
Anyway it affects little, removing it perhaps improve performance a little.
cloudwu commentedon Sep 24, 2013
I mean
wilsonwen commentedon Sep 24, 2013
Do you worried about "return s" runs before "if (s->type == 0)" or "cstring_clone"?
But I can't tell the problem it cause without '__sync_synchronize();'.
cloudwu commentedon Sep 24, 2013
yeah, maybe s was read by flowing cstring_grab() before s->type changed.
I'm not sure. But I guess I can remove these '__sync_synchronize();'
remove __sync_synchronize #1
Revert "remove __sync_synchronize cloudwu#1"