Using an unsafe component with a multi-threaded component (Design)

Design problem:

Using a non-streaming component (Collection, API, ...) in / with a multi-threaded component ...

Example:

component1 : multithreaded socket serverthat sends messages ... to a message handler

component2 . A non-flowing message handler that processes messages ... from the server

My decision:

By adding a thread-safe component ( buffer ) between the server and the message handler, the buffer will receive messages with a multi-threaded image from the server and send them in the same order for the message handler in one thread .

My question is:

Is there a better solution? Can the appropriate design pattern be a proxy or a pipeline ?

+3
source share
4 answers

One of the very nice options is to use the Producer / Consumer template .

, , , , . .

+5

" ": , - .

+3

, API ,

+3

, 2 ...

2 :
, . , ...

+1

Source: https://habr.com/ru/post/1726467/


All Articles