What is the difference in writing to files atomically on the iPhone in objective-c and not, is there any performance difference between the two?
What is the difference in writing to files atomically on the iPhone in objective-c
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Atomic in general means the operation
cannot be interruptedwill complete or have no effect. When writing files, that is accomplished by writing to a temporary file then replacing the original with the temporary when the write completes.A crash while writing an atomic file means the original is not modified and there is a garbage file that can be deleted. A crash while writing normally would mean an expected good file is corrupt.
Performance wise the cost is minimal. During the write you will have two copies of a file. The file replace is a very simple operation at the file system level.
Edit: thanks zneak