Skip to content

Commit 9288406

Browse files
committed
Document thread-safety for setupThreadSafeEndpoint
1 parent 3007c09 commit 9288406

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

core/src/main/scala/org/apache/spark/rpc/RpcEnv.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,14 @@ private[spark] trait RpcEnv {
5555
/**
5656
* Register a [[RpcEndpoint]] with a name and return its [[RpcEndpointRef]]. [[RpcEnv]] should
5757
* make sure thread-safely sending messages to [[RpcEndpoint]].
58+
*
59+
* Thread-safety means processing of one message happens before processing of the next message by
60+
* the same [[RpcEndpoint]]. In the other words, changes to internal fields of a [[RpcEndpoint]]
61+
* are visible when processing the next message, and fields in the [[RpcEndpoint]] need not be
62+
* volatile or equivalent.
63+
*
64+
* However, there is no guarantee that the same thread will be executing the same [[RpcEndpoint]]
65+
* for different messages.
5866
*/
5967
def setupThreadSafeEndpoint(name: String, endpoint: RpcEndpoint): RpcEndpointRef
6068

0 commit comments

Comments
 (0)