Say if your boss's mood is frustrated and he takes out the entire heat on you, then you should say in front of him "Boss, if you talk to me like me like this then this would affect my work" and this works (if you talk to him with politeness).