App Engine just became a more interesting Clojure platform now that Google 
has opened Compute Engine to everyone and has provided a way to use sockets 
and threads.

Has anyone adapted Clojure to work with App Engine's new ThreadManager and 
Sockets APIs?

The experimental sockets API enables you to connect to Compute Engine 
servers from App Engine:

https://developers.google.com/appengine/docs/java/sockets/overview

And until recently AppEngine didn't permit threads so Clojure's agents and 
futures would work, but now you can execute short-lived threads through the 
ThreadManager API:

   - 
   
https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/ThreadManager
   
There are some restrictions though -- "each request is limited to 50 
concurrent request threads", and "you cannot invoke new Thread() yourself 
or use the default thread factory."

>From https://developers.google.com/appengine/docs/java/runtime#The_Sandbox
 ...
Threads

A Java application can create a new thread, but there are some restrictions 
on how to do it. These threads can't "outlive" the request that creates 
them. (On a backend server, an application can spawn a background 
thread<https://developers.google.com/appengine/docs/java/backends/overview#background_threads>,
 
a thread that can "outlive" the request that creates it.)

An application can

   - Implement java.lang.Runnable; and
   - Create a thread factory by calling 
   
com.google.appengine.api.ThreadManager.currentRequestThreadFactory()<https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/ThreadManager#currentRequestThreadFactory()>
   - call the factory's newRequestThread method, passing in the Runnable, 
   newRequestThread(runnable)

or use the factory object returned by 
com.google.appengine.api.ThreadManager.currentRequestThreadFactory()<https://developers.google.com/appengine/docs/java/javadoc/com/google/appengine/api/ThreadManager#currentRequestThreadFactory()>
 with 
an ExecutorService (e.g., callExecutors.newCachedThreadPool(factory)).

However, you must use one of the methods on ThreadManager to create your 
threads. You cannot invoke new Thread() yourself or use the default thread 
factory<http://docs.oracle.com/javase/6/docs/api/java/util/concurrent/Executors.html#defaultThreadFactory>
.

An application can perform operations against the current thread, such as 
thread.interrupt().

Each request is limited to 50 concurrent request threads.

---//---

- James


-- 
-- 
You received this message because you are subscribed to the Google
Groups "Clojure" group.
To post to this group, send email to clojure@googlegroups.com
Note that posts from new members are moderated - please be patient with your 
first post.
To unsubscribe from this group, send email to
clojure+unsubscr...@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/clojure?hl=en
--- 
You received this message because you are subscribed to the Google Groups 
"Clojure" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to clojure+unsubscr...@googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Reply via email to