Skip to content

Adds documentation regarding thread safety of CompilerPipeline #334

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Dec 15, 2020
Merged
Show file tree
Hide file tree
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
10 changes: 9 additions & 1 deletion lang/src/org/partiql/lang/CompilerPipeline.kt
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,10 @@ typealias ProcessingStep = (ExprNode, StepContext) -> ExprNode
/**
* [CompilerPipeline] is the main interface for compiling PartiQL queries into instances of [Expression] which
* can be executed.
*
* The provided builder companion creates an instance of [CompilerPipeline] that is NOT thread safe and should NOT be
* used to compile queries concurrently. If used in a multithreaded application, use one instance of [CompilerPipeline]
* per thread.
*/
interface CompilerPipeline {
val valueFactory: ExprValueFactory
Expand Down Expand Up @@ -93,7 +97,11 @@ interface CompilerPipeline {
builder(valueFactory).build()
}

/** An implementation of the builder pattern for instances of [CompilerPipeline]. */
/**
* An implementation of the builder pattern for instances of [CompilerPipeline]. The created instance of
* [CompilerPipeline] is NOT thread safe and should NOT be used to compile queries concurrently. If used in a
* multithreaded application, use one instance of [CompilerPipeline] per thread.
*/
class Builder(val valueFactory: ExprValueFactory) {
private var parser: Parser? = null
private var compileOptions: CompileOptions? = null
Expand Down
3 changes: 2 additions & 1 deletion lang/src/org/partiql/lang/eval/EvaluatingCompiler.kt
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ import kotlin.collections.*
* [here][1].
*
* **Note:** *threaded* in this context is used in how the code gets *threaded* together for
* interpretation and **not** the concurrency primitive.
* interpretation and **not** the concurrency primitive. That is to say this code is NOT thread
* safe.
*
* [1]: https://www.complang.tuwien.ac.at/anton/lvas/sem06w/fest.pdf
*
Expand Down