I can't seem to find a good and accessible explanation of "Leader/Follower" pattern. All explanations are simply completely meaningless as in 1.
Can anyone explain to the the mechanics of how this pattern works, and why and how it improves performance over more traditional asynchronous IO models? Examples and links to diagrams are appreciated too.
Leaders are willing to step up and take control of a project or task. They enjoy a challenge and embrace change as they know it will benefit them in the long term. Followers have to be forced to drive a project by their boss. They rarely, if ever, volunteer to take on a project.
Kelley (1992) posited that there are five followership styles. These include exemplary, conformist, passive, alienated and pragmatist styles (Kelley, 1992). These followership styles are based on a combination of two different followership dimensions: engagement and critical thinking (Kelley, 1992).
Leaders and followers are influenced by each other Leaders influence their followers according to the company's needs, while followers influence leaders with their attitude and actions – it can have both positive and negative impacts.
As you might have read, the pattern consists of 4 components: ThreadPool, HandleSet, Handle, ConcreteEventHandler (implements the EventHandler interface).
You can think of it as a taxi station at night, where all the drivers are sleeping except for one, the leader. The ThreadPool is a station managing many threads - cabs.
The leader is waiting for an IO event on the HandleSet, like how a driver waits for a client.
When a client arrives (in the form of a Handle identifying the IO event), the leader driver wakes up another driver to be the next leader and serves the request from his passenger.
While he is taking the client to the given address (calling ConcreteEventHandler and handing over Handle to it) the next leader can concurrently serve another passenger.
When a driver finishes he take his taxi back to the station and falls asleep if the station is not empty. Otherwise he become the leader.
The pros for this pattern are:
The cons are:
I want to add to Jake's answer by linking another PDF from the same author that details a use case where they chose the Leader/Follower pattern over other alternatives: http://www.dre.vanderbilt.edu/~schmidt/PDF/OM-01.pdf
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With