vishnu viswanath
vishnu viswanath

Reputation: 3854

reactor vs proactor

Could anyone explain the difference between reactor-pattern and proactor-pattern? I know that in reactor-pattern the operations are synchronous and in proactor they're asynchronous and also that in reactor the operation is done by the handler which is handed over to the client by the reactor. (correct me if i am wrong)

Also Which of these pattern is used in case of fail safe and which is used in fail fast?

Upvotes: 21

Views: 9794

Answers (3)

NoSenseEtAl
NoSenseEtAl

Reputation: 30028

Doug Schmidt explains this in his video lecture.

They are very similar, but Reactor deals with initialization events, Proactor with completion events.

Reactor pattern : Call me when I can do X.

Proactor pattern: Do X and call me when you are done.

Upvotes: 0

Aqua
Aqua

Reputation: 754

In reactor pattern you will poll device for readiness to do something, while in proactor you do something and poll for its completion.

The good examples for reactor pattern are: epoll(Linux), kqueue(MacOS, FreeBSD), select(Linux, MacOS, Windows) approaches. The good example for proactor pattern is Windows IOCP approach.

Upvotes: 6

Matthew Hammel
Matthew Hammel

Reputation: 104

Referencing Fail fast or fail safe? as well as wiki articles I would say that proactor is fail-safe and reactor is fail-fast. Proactor having a completion handler gives it a more "safe" approach. A synchronous environment such as reactor will have large fail if one task fails while blocking a large amount of resources. Hope this helps.

Upvotes: 3

Related Questions