File tree 1 file changed +11
-2
lines changed
1 file changed +11
-2
lines changed Original file line number Diff line number Diff line change @@ -5,10 +5,19 @@ import java.io.FileWriter
5
5
/** @author Stephen Samuel */
6
6
object Invoker {
7
7
8
+ /**
9
+ * We record that the given id has been invoked by appending its id to the coverage
10
+ * data file.
11
+ * This will happen concurrently on as many threads as the application is using,
12
+ * but appending small amounts of data to a file is atomic on both POSIX and Windows
13
+ * if it is a single write of a small enough string.
14
+ *
15
+ * @see http://stackoverflow.com/questions/1154446/is-file-append-atomic-in-unix
16
+ * @see http://stackoverflow.com/questions/3032482/is-appending-to-a-file-atomic-with-windows-ntfs
17
+ */
8
18
def invoked (id : Int , path : String ) = {
9
19
val writer = new FileWriter (path, true )
10
- writer.append(id.toString)
11
- writer.append(';' )
20
+ writer.append(id.toString + ';' )
12
21
writer.close()
13
22
}
14
23
}
You can’t perform that action at this time.
0 commit comments