[Aglets-developer] Aglet thread sleep support!
Status: Beta
Brought to you by:
cat4hire
From: Luca F. <cat...@us...> - 2005-10-07 16:19:52
|
Hi, I've just posted a few changes to the CVS in order to support the sleep(..) operation over an agent. In other words, being in an aglet code is now possible to call the special method sleep(long timeout) to suspend an agent for the specified timeout. The sleep operation has been implemented as follows: the message manager is suspended, that means it continues enqueing incoming messages but it does not process them; then the current thread is set to sleep and, when the sleep ends, the message manager wakes up. Once the message manager wakes up, other came messages are processed. This means that, while an agent is sleeping, no messages are processed, and this is right accordingly to the sleep semantic. However, this also means that the thread in charge of delivering the message, e.g., another agent, waits until the agent wakes up. This can be a problem, since a sending agent has no idea of how many seconds the receiver agent will sleep. To overtake this limitation (and here I need your opinion guys), I created a special thead, the com.ibm.aglets.thread.DeliveryMessageThread, that is a thread in charge of delivering a message. Thus, this glue thread, simply takes care of the message, waiting until the addresse agent wakes up, and then it delivers the message. Of course, the deliver is now asynchronous and the sender agent/thread can continue with its work. If the reply is required, the sender must use the future reply facility, because the delivery thread does not provide any mechanism to control it. What do you think? Luca -- +-------------------------------+ Luca Ferrari cat...@us... The Aglets Project: http://aglets.sourceforge.net +-------------------------------+ |