Timeline for Implementing a shared array cache without locking
Current License: CC BY-SA 3.0
16 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Dec 29, 2014 at 16:20 | history | rollback | Jamal |
Rollback to Revision 3
|
|
Mar 27, 2012 at 22:15 | history | edited | gcbenison | CC BY-SA 3.0 |
explained choice of correct answer
|
Mar 27, 2012 at 22:12 | vote | accept | gcbenison | ||
Mar 21, 2012 at 19:39 | answer | added | William Morris | timeline score: 2 | |
Mar 18, 2012 at 7:33 | answer | added | stderr | timeline score: 2 | |
Mar 17, 2012 at 17:44 | comment | added | gcbenison | @loki Arghh... thanks for pointing this out. Edited to fix. This code is paraphrased, not copied, from the original source (which does have tests). So the code pasted here hasn't been tested. | |
Mar 17, 2012 at 17:43 | history | edited | gcbenison | CC BY-SA 3.0 |
revert first edit; manipulate actual cache, not a local copy of the slot
|
Mar 17, 2012 at 17:40 | history | tweeted | twitter.com/#!/StackCodeReview/status/181072453928353794 | ||
Mar 17, 2012 at 17:16 | comment | added | gcbenison |
@joey I'll have to look at the callers in more detail to see if multiple threads attempt to set the same owner . If not, I can see how that could simplify the problem.
|
|
Mar 17, 2012 at 17:16 | comment | added | Loki Astari |
This is an error: struct slot = cache[idx]; Here you are making a copy of the cache content. Then you modify this copy in the function (you never touch the cache). Thus the cache is never updated. This means the code is non functional (do you actually have unit tests?).
|
|
Mar 17, 2012 at 17:12 | comment | added | gcbenison |
@joey about slot not being a pointer - you're right; I am paraphrasing this code from elsewhere and made that mistake. Edited to fix
|
|
Mar 17, 2012 at 17:10 | history | edited | gcbenison | CC BY-SA 3.0 |
fixed mistake: 'slot' is a struct, not a pointer to a struct
|
Mar 17, 2012 at 14:54 | comment | added | Joey Adams |
Also, is it possible for two different threads to call store with the same owner object?
|
|
Mar 17, 2012 at 14:48 | comment | added | Joey Adams |
Err, struct _cache_slot *slot = &cache[idx] .
|
|
Mar 17, 2012 at 14:42 | comment | added | Joey Adams |
Shouldn't slot be declared as a pointer? As in, struct *slot = &cache[idx]; . That's how you're accessing it.
|
|
Mar 16, 2012 at 19:27 | history | asked | gcbenison | CC BY-SA 3.0 |