|
01/05/2013 05:41 PM
Pretty cool solution. To add to that, it works great when pceross collision is greater than the granularity of the MySql timestamp which is per second. ie, no 2 pceross will do a read/write within 1 second.To get around this, you can store the time as a bigint which can handle milliseconds. Unless you have some serious hardware, I don't think collision granularity would go smaller than milliseconds.Also instead of re-reading the timestamp before B saves, B should try to UPDATE row WHERE opened timestamp = last modified timestamp . Otherwise the CPU could potentially decide to switch threads on you right after you've done the second read, and do the entire read-write of A in that time.
|