You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/11/10 03:32:57 UTC

[GitHub] [pulsar] BewareMyPower added a comment to the discussion: [QUESTION] Thread safe problem about HandlerState#changeToReadyState

GitHub user BewareMyPower added a comment to the discussion: [QUESTION] Thread safe problem about HandlerState#changeToReadyState

Is following implementation better?

```java
    private static boolean notClosed(State state) {
        return state == State.Uninitialized || state == State.Connecting || state == State.RegisteringSchema;
    }

    // moves the state to ready if it wasn't closed
    protected boolean changeToReadyState() {
        return STATE_UPDATER.getAndUpdate(this, state -> (notClosed(state) ? State.Ready : state)) == State.Ready;
    }

```

GitHub link: https://github.com/apache/pulsar/discussions/18401#discussioncomment-4103573

----
This is an automatically sent email for dev@pulsar.apache.org.
To unsubscribe, please send an email to: dev-unsubscribe@pulsar.apache.org