Home / Function/ add() — netty Function Reference

add() — netty Function Reference

Architecture documentation for the add() function in DefaultChannelGroup.java from the netty codebase.

Function java Buffer Search called by 1

Entity Profile

Dependency Diagram

graph TD
  4d0e5010_2e39_3533_9d5c_db2eee504dfe["add()"]
  6d7f33a8_3187_e4ea_396d_f62be954d07b["DefaultChannelGroup"]
  4d0e5010_2e39_3533_9d5c_db2eee504dfe -->|defined in| 6d7f33a8_3187_e4ea_396d_f62be954d07b
  35c79e04_74bc_7829_a6a7_e0728e9bb727["ChannelGroupFuture()"]
  35c79e04_74bc_7829_a6a7_e0728e9bb727 -->|calls| 4d0e5010_2e39_3533_9d5c_db2eee504dfe
  style 4d0e5010_2e39_3533_9d5c_db2eee504dfe fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

transport/src/main/java/io/netty/channel/group/DefaultChannelGroup.java lines 136–163

    @Override
    public boolean add(Channel channel) {
        ConcurrentMap<ChannelId, Channel> map =
            channel instanceof ServerChannel? serverChannels : nonServerChannels;

        boolean added = map.putIfAbsent(channel.id(), channel) == null;
        if (added) {
            channel.closeFuture().addListener(remover);
        }

        if (stayClosed && closed) {

            // First add channel, than check if closed.
            // Seems inefficient at first, but this way a volatile
            // gives us enough synchronization to be thread-safe.
            //
            // If true: Close right away.
            // (Might be closed a second time by ChannelGroup.close(), but this is ok)
            //
            // If false: Channel will definitely be closed by the ChannelGroup.
            // (Because closed=true always happens-before ChannelGroup.close())
            //
            // See https://github.com/netty/netty/issues/4020
            channel.close();
        }

        return added;
    }

Domain

Subdomains

Frequently Asked Questions

What does add() do?
add() is a function in the netty codebase, defined in transport/src/main/java/io/netty/channel/group/DefaultChannelGroup.java.
Where is add() defined?
add() is defined in transport/src/main/java/io/netty/channel/group/DefaultChannelGroup.java at line 136.
What calls add()?
add() is called by 1 function(s): ChannelGroupFuture.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free