What does function eventloop do in Scala Actors and what is it useful for?
What does function eventloop do in Scala Actors and what is it useful for?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
eventloopworks similarly toloopandreactbeing combined. The difference betweenloopandeventloopis thatloop, in fact, doesn’t call the body recursively (to prevent stack overflow for thread-based actors), but schedules handling (react/receive) of a next message from the mailbox, and finishes execution of a current handler throwing an exception, to clear up the call stack.eventlooprecursively handles the messages usingreact– in case ofreactit’s safe (and stack doesn’t get overflown), because the body ofreact(but notreceive!) always ends with an exception, in the most cases, and the next loop scheduled, to guarantee a fair access to the thread pool form all actors. Therefore,eventloopcan be used only with event-driven actors.