Skip to content

Commit

Permalink
Remove biased locking related comments which seems out dated as we tr…
Browse files Browse the repository at this point in the history
…y to avoid it on the hot path
  • Loading branch information
vietj committed Oct 13, 2024
1 parent 6d98edb commit 4c9d707
Show file tree
Hide file tree
Showing 13 changed files with 0 additions and 83 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ boolean setRemoved() {
return unregistered;
}

// Because of biased locks the overhead of the synchronized lock should be very low as it's almost always
// called by the same event loop
public synchronized boolean isRemoved() {
return removed;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
import java.util.*;

/*
* This class is optimised for performance when used on the same event loop it was created on.
* However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*/
public class MessageConsumerImpl<T> extends HandlerRegistration<T> implements MessageConsumer<T> {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,13 +47,6 @@
import java.util.concurrent.atomic.AtomicInteger;

/**
*
* This class is optimised for performance when used on the same event loop that is was passed to the handler with.
* However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class AsyncFileImpl implements AsyncFile {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,12 +61,6 @@
import static io.vertx.core.http.HttpHeaders.*;

/**
*
* This class is optimised for performance when used on the same event loop. However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class Http1xClientConnection extends Http1xConnection implements HttpClientConnectionInternal {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,14 +47,6 @@
import static io.vertx.core.spi.metrics.Metrics.METRICS_ENABLED;

/**
* This class is optimised for performance when used on the same event loop that is was passed to the handler with.
* However it can be used safely from other threads.
* <p>
* The internal state is protected by using the connection as a lock. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
* <p>
* It's important we don't have different locks for connection and request/response to avoid deadlock conditions
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class Http1xServerRequest extends HttpServerRequestInternal implements io.vertx.core.spi.observability.HttpRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,15 +49,6 @@
import static io.vertx.core.http.HttpHeaders.*;

/**
*
* This class is optimised for performance when used on the same event loop that is was passed to the handler with.
* However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* It's important we don't have different locks for connection and request/response to avoid deadlock conditions
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class Http1xServerResponse implements HttpServerResponse, HttpResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,6 @@
import static io.vertx.core.http.impl.HttpClientImpl.ABS_URI_START_PATTERN;

/**
* This class is optimised for performance when used on the same event loop that is passed to the handler with.
* However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* This class uses {@code this} for synchronization purpose. The {@link #client} or{@link #stream} instead are
* called must not be called under this lock to avoid deadlocks.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class HttpClientRequestImpl extends HttpClientRequestBase implements HttpClientRequest {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,6 @@
import java.util.List;

/**
* This class is optimised for performance when used on the same event loop that is was passed to the handler with.
* However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class HttpClientResponseImpl implements HttpClientResponse {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,6 @@
import java.nio.charset.Charset;

/**
* This class is optimised for performance when used on the same event loop that is was passed to the handler with.
* However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="mailto:[email protected]">Norman Maurer</a>
*/
class HttpServerFileUploadImpl implements HttpServerFileUpload {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,20 +11,13 @@

package io.vertx.core.http.impl;

import io.vertx.core.*;
import io.vertx.core.http.ServerWebSocket;
import io.vertx.core.internal.ContextInternal;
import io.vertx.core.net.HostAndPort;
import io.vertx.core.net.impl.VertxConnection;

/**
* This class is optimised for performance when used on the same event loop. However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*
*/
public class ServerWebSocketImpl extends WebSocketImplBase<ServerWebSocketImpl> implements ServerWebSocket {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,7 @@
import io.vertx.core.net.impl.VertxConnection;

/**
* This class is optimised for performance when used on the same event loop. However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*
*/
public class WebSocketImpl extends WebSocketImplBase<WebSocketImpl> implements WebSocket {

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,6 @@
import static io.vertx.core.net.impl.VertxHandler.*;

/**
* This class is optimised for performance when used on the same event loop. However it can be used safely from other threads.
* <p>
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="http://tfox.org">Tim Fox</a>
* @param <S> self return type
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,6 @@
import java.util.concurrent.TimeUnit;

/**
*
* This class is optimised for performance when used on the same event loop that is was passed to the handler with.
* However it can be used safely from other threads.
*
* The internal state is protected using the synchronized keyword. If always used on the same event loop, then
* we benefit from biased locking which makes the overhead of synchronized near zero.
*
* @author <a href="http://tfox.org">Tim Fox</a>
*/
public class NetSocketImpl extends VertxConnection implements NetSocketInternal {
Expand Down

0 comments on commit 4c9d707

Please sign in to comment.