Merge lp:~lsinger/play/1.1 into lp:play/1.1

Proposed by Leif Singer
Status: Merged
Merged at revision: not available
Proposed branch: lp:~lsinger/play/1.1
Merge into: lp:play/1.1
Diff against target: 79 lines (+16/-9)
2 files modified
framework/src/play/Invoker.java (+8/-8)
framework/src/play/mvc/Controller.java (+8/-1)
To merge this branch: bzr merge lp:~lsinger/play/1.1
Reviewer Review Type Date Requested Status
play framework developers Pending
Review via email: mp+16676@code.launchpad.net
To post a comment you must log in.
Revision history for this message
Leif Singer (lsinger) wrote :

Fixes bug #501665 - Controller.suspend doesn't allow subsecond suspend times.

lp:~lsinger/play/1.1 updated
721. By guillaume <guillaume@gbo-mac>

Merge 1.0

Revision history for this message
Guillaume Bort (guillaume-bort) wrote :

Ok merged. Another cool feature we could provide in this room is:

protected static void waitFor(Future tasks...) {
}

It could wait for several tasks completions before resuming the request.

lp:~lsinger/play/1.1 updated
722. By guillaume <guillaume@gbo-mac>

Merge

Revision history for this message
Leif Singer (lsinger) wrote :

> Ok merged. Another cool feature we could provide in this room is:
>
> protected static void waitFor(Future tasks...) {
> }
>
> It could wait for several tasks completions before resuming the request.

Thanks a lot for merging so quickly! It's nice to have own code in my favorite server-side framework. :)

As for the waitFor for multiple Futures: it looks like it would be useful for some, but then again, I've actually never worked with Futures, so I couldn't even tell whether it works correctly. So I guess I should leave that one to you to decide.

Regards
  Leif

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1=== modified file 'framework/src/play/Invoker.java'
2--- framework/src/play/Invoker.java 2009-11-17 12:59:06 +0000
3+++ framework/src/play/Invoker.java 2009-12-30 15:53:13 +0000
4@@ -40,13 +40,13 @@
5 /**
6 * Run the code in a new thread after a delay
7 * @param invocation The code to run
8- * @param seconds The time to wait before
9+ * @param millis The time to wait before, in milliseconds
10 * @return The future object, to know when the task is completed
11 */
12- public static Future invoke(final Invocation invocation, int seconds) {
13+ public static Future invoke(final Invocation invocation, long millis) {
14 Monitor monitor = MonitorFactory.getMonitor("Invocation queue", "elmts.");
15 monitor.add(executor.getQueue().size());
16- return executor.schedule(invocation, seconds, TimeUnit.SECONDS);
17+ return executor.schedule(invocation, millis, TimeUnit.MILLISECONDS);
18 }
19
20 /**
21@@ -64,7 +64,7 @@
22 if (invocation.retry.task != null) {
23 invocation.retry.task.get();
24 } else {
25- Thread.sleep(invocation.retry.timeout * 1000);
26+ Thread.sleep(invocation.retry.timeout);
27 }
28 } catch (Exception e) {
29 throw new UnexpectedException(e);
30@@ -219,16 +219,16 @@
31 public static class Suspend extends PlayException {
32
33 /**
34- * Suspend for a timeout (in seconds).
35+ * Suspend for a timeout (in milliseconds).
36 */
37- int timeout;
38+ long timeout;
39
40 /**
41 * Wait for task execution.
42 */
43 Future task;
44
45- public Suspend(int timeout) {
46+ public Suspend(long timeout) {
47 this.timeout = timeout;
48 }
49
50@@ -246,7 +246,7 @@
51 if (task != null) {
52 return "Wait for " + task;
53 }
54- return "Retry in " + timeout + " s.";
55+ return "Retry in " + timeout + " ms.";
56 }
57 }
58
59
60=== modified file 'framework/src/play/mvc/Controller.java'
61--- framework/src/play/mvc/Controller.java 2009-11-22 18:32:54 +0000
62+++ framework/src/play/mvc/Controller.java 2009-12-30 15:53:14 +0000
63@@ -540,8 +540,15 @@
64 * Suspend the current request for a specified amount of time
65 */
66 protected static void suspend(String timeout) {
67+ suspend(1000 * Time.parseDuration(timeout));
68+ }
69+
70+ /**
71+ * Suspend the current request for a specified amount of time (in milliseconds)
72+ */
73+ protected static void suspend(int millis) {
74 Request.current().isNew = false;
75- throw new Suspend(Time.parseDuration(timeout));
76+ throw new Suspend(millis);
77 }
78
79 /**

Subscribers

People subscribed via source and target branches