Ssh:[email Protected]:unbelievableme/object-pool.git
Https:https://github.com/unbelievableme/object-pool.git
Buffer pool
Design Essentials : Contains three queues: an empty buffer queue (EMQ), an input queue full of input data (INQ), an output queue full of output data (OUTQ), an input program that includes a host input (Hin), an extract input (sin), and an output program that includes a host output (Hout) and extract output (sout).
Note : The input program and the output program have concurrent access to the buffer, so you can set a mutually exclusive semaphore on the buffer, or lock the operation on the buffer. There is also a synchronization relationship between the Hin,sin,hout,sout, which can be determined by the IF statement to determine the order of execution
Thread pool
Design Essentials : The thread pool, like threads, also has the most basic readiness, run, end, and so on. The Threadpoolservice class contains State,threadcount, a thread container, a task container, and other member variables, which are initialized when a certain number of threads are added to the thread container (initialization of threads passes in a This parameter, indicating the thread pool to which he belongs), For each thread, a task container is obtained within the Run method, and if the container contains a ready task, execute it, that is, the task takes up the thread, and the thread executes the task in the form of polling (or other design),
Note : threads, task containers have concurrent access to tasks (changing the state of a task), so the operation on the task needs to be locked.
Connection pool
Design Point : ConnectionPool is initialized with a number of connection, at the high level through getconnection to obtain a connection in the container, If there is no connection in the container to initialize a connection (), when the database operation is not required, the traditional practice is to release the connection, and for the connection pool is in the container, to restore the inclusion of the connection
Note : Connection pooling has concurrent access to connection, so the operation on connection should be locked
Contrast
The same point: whether it is the buffer pool, the object pool or the connection pool, originally designed to increase the utilization of system resources, is the system overhead more on the specific request processing rather than the creation and release of the object, since it is a container, there are many similarities in the design of the class, for example: initialization , the design of member variables, and so on.
different points: the so-called different points are also produced at the same point, such as mutual exclusion, definition of synchronous semaphore, connection, thread, reuse strategy of buffer pool.
Buffer pool, thread pool, connection pool