Reactor pattern summary

Reactor be multiplexed is based on a model in NIO.

What is the Reactor pattern
  1. Synchronization source to wait for multiple events (using select () realize)
  2. The event demultiplexing and assign corresponding event processing service, the dispatch server using centralized processing (dispatch)
  3. Separation Decomposition of the event and the corresponding event service application from dispatch service out (handler)
Why Reactor mode

Common network services, if each client to maintain a connection to the server and log in. Then the server and client to maintain multiple connections to come out and contnect clients, read, write, especially for the long link service, the number of c-side, you need to maintain the same IO connection s end. This is a significant overhead for the server.

Three kinds of Reactor model
  1. Single Reactor single-threaded model


  2. Single Reactor multi-threaded model


  3. Multi-Reactor multi-threaded model


Original Address: https://www.jianshu.com/p/fc6f4fd617cb

Guess you like

Origin www.cnblogs.com/jpfss/p/10936342.html