Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 11 additions & 2 deletions src/main/scala/scoverage/Invoker.scala
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,19 @@ import java.io.FileWriter
/** @author Stephen Samuel */
object Invoker {

/**
* We record that the given id has been invoked by appending its id to the coverage
* data file.
* This will happen concurrently on as many threads as the application is using,
* but appending small amounts of data to a file is atomic on both POSIX and Windows
* if it is a single write of a small enough string.
*
* @see http://stackoverflow.com/questions/1154446/is-file-append-atomic-in-unix
* @see http://stackoverflow.com/questions/3032482/is-appending-to-a-file-atomic-with-windows-ntfs
*/
def invoked(id: Int, path: String) = {
val writer = new FileWriter(path, true)
writer.append(id.toString)
writer.append(';')
writer.append(id.toString + ';')
writer.close()
}
}