As a #guru, let me pay my respects today to my #guru in the tech world, who has influenced my technical skills and mindset.
Although I have never seen them, nor do they know I exist.
But I am grateful to them - and because of them, I have at last become an engineer in the true sense.
First guru: The authors of The Gang of Four Design Pattern Book
Second Guru: Linus Torvalds for offering Linux and rather helping me come out of the vicious cycle of windows
Third Guru: The Android creator and Google for showing me the different nitty-gritty of a complicated framework that i learnt through delving into the Android framework code
Fourth Guru: A professor of a USA University by the name Doug, from whom I got insights of how to study the Android OS difficult parts of the code like the AsyncTask Framework, and he showed me the right approach of taking the OS study from an engineer’s perspective - delving into the difficult concurrent framework of the Android OS
And my all-time Guru: My family for giving me a sweet, caring, loving #home and my only son, #ridit, for becoming my best student from his early childhood. He is still driving me to burn the midnight oil in front of the laptop to explore the deep ocean of Computer science.
And I am sure, the way the whole professional world of technology is moving, very soon somebody will have to dismiss the book called
#theworldisflat - The World Is Flat
and write a new one
#theflatistheworld - The Flat Is The World
Runtime Behaviour
- The application creates the Context.
- The Context delegates execution to the current State.
- The State starts a Timer.
- The Timer expires.
- The Timer invokes the notification callback.
- The callback requests the Context to change its current State.
- The Context delegates subsequent operations to the new State.
#ifndef MAMMA_H_
#define MAMMA_H_
#include <memory>
#include <atomic>
#include "Callback.h"
#include "ChickenState.h"
#include "timer.h"
class Mamma : public Callback {
private:
std::unique_ptr<ChickenState> currentState;
public:
Timer t;
std::atomic<bool> timerRunning{true};
// Flags tracking state milestones safely
std::atomic<bool> isUncleanedStateDone{false};
std::atomic<bool> isCleanedStateDone{false};
std::atomic<bool> isMarinatedStateDone{false};
std::atomic<bool> isCookedStateDone{false};
Mamma();
~Mamma() override = default;
void changeChickenState(std::unique_ptr<ChickenState> nextState);
void startPreparation();
void goToNextStateFromCallback() override;
ChickenState* getCurrentState() { return currentState.get(); }
};
#endif
To compile the above code, we need to activate the -pthread option for the compiler and linker.
Enjoy...


