New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
how to use jactor #14
Comments
The example I gave above uses 10 threads, so it can process 10 requests at a time. The driver creates n workers, each with its own asynchronous mailbox, and sends each one a request. The driver exits when it has received responses for all the requests sent. In production code, you would also want to use an exception handler so you can treat any raised exceptions as responses as well. |
I should perhaps clarify a bit. Threads are expensive, so to service lots of simultaneous users you should not dedicate a separate thread to each request. Now a lot of modern web servers, Jetty being just one, support continuations. Integrating web server continuations with actors is one way to do things while minimizing thread usage--actors being light-weight threads. |
thank you very much,I'll try it |
Keep in mind that, except when doing I/O, actors should never block. And there are no locks anywhere. |
hi, laforge49. |
Yes, this is important. I/O can be done is a separate actor, which has its own dedicated asynchronous mailbox. Actors which then send a request to this I/O actor then will not get a response until the I/O completes, but are not blocked in that they can still process other requests. The other thing that you need to realize is that when an actor is processing a request, it can send a request to that I/O actor and still do other things, like sending a response to the request they are processing. But then what do you do when you do get that response from the I/O actor? Remember that for each request received, an actor can send only one response. So it gets tricky. So it comes down to your top-level design. You get a request from an actor and you want to (1) initiate some activity and also (2) respond to the user. So what do you then do when that (asynchronous) activity completes? Do you want to (a) update some state which will effect some future request by the user? (AJAX-like) Or do you want to send an update to the user? (CometD-like?) Bill |
Ok . |
Lets leave this issue open for now. I think this discussion is valuable and would be visible to a wider community if left open. |
hi, laforge49 |
I do hope the changes I've been making do not cause you problems. My current plan is to drop JBActor, Component and all their subclasses, leaving only JLPCActor and its subclasses. But before I do this I need to rewrite a number of components as actors, as components will no longer be supported. What has happened is that JLPCActors have become very light-weight, allowing the creation of more than a billion of them each second, as well as becoming more powerful. By dropping JBActor, I lose composition but nothing else. JBActors (and the subclass, JCActor) are quite slow in comparison and add a lot of complexity to the project. |
I just use JLPCActors and JAEvent,hehe |
I write an appender for logback with jactor ,It's here https://github.com/cp149/jactor-logger |
Very nice! I was thinking that I would have to write that myself, so I am I've placed a link to your project here: Meanwhile we have been working on the next generation of Jactor, which you API: https://github.com/laforge49/PActor Here's some comparisons with other actor frameworks: Everything works, but we are still adding additional speedups to the For the moment, there are no docs, except for the javadocs in PActor. And But this time around, I'm not working alone.And the code is ever so much Bill On Sat, Apr 6, 2013 at 11:06 AM, cp149 notifications@github.com wrote:
|
cp149, I dug into your code a bit and I think it is a great application for The logback project has some known issues regarding closing, i.e. if it is Of course, I understand from Monster that JASocket also has an issue Bill On Sat, Apr 6, 2013 at 12:19 PM, William la Forge laforge49@gmail.comwrote:
|
Glad to see you have start next generation of Jactor. It is a great project,very fast and stable.It has run with my project in the past year. |
Many thanks for the kind words. Consider also joining our group: Bill On Sun, Apr 7, 2013 at 8:30 AM, champion notifications@github.com wrote:
|
hi,laforge49
I'm new to Jactor,I got code,and run the test ,It is fast.I read your document,but can not find a right way to use in my web app.
my web app is very simple,user input a task,every task run 10-100 second.I write a unit test such as blow
public class TaskTest {
//queuque to save taskids
LinkedBlockingQueue taskqueque=new LinkedBlockingQueue();
//flag,stop taskserver
boolean stop=false;
}
can you give me a sample how to use jactor in this class? thank you very much.
The text was updated successfully, but these errors were encountered: