Changes for page Building Concurrent Applications with WebObjects and Scala
Last modified by Ravi Mendis on 2012/02/11 08:28
From version 141.1
edited by Ravi Mendis
on 2010/04/05 21:18
on 2010/04/05 21:18
Change comment:
There is no comment for this version
To version 140.1
edited by Ravi Mendis
on 2010/03/04 00:11
on 2010/03/04 00:11
Change comment:
There is no comment for this version
Summary
-
Page properties (1 modified, 0 added, 0 removed)
Details
- Page properties
-
- Content
-
... ... @@ -1,38 +1,14 @@ 1 -Given that processors todayship with dual or quad cores and server processors ship with between 8 to 32 cores,programs developed in languages like Java, Ruby, Groovy,Python and Perl are struggling toexploit all that power. On the other hand, Scala, as its name suggests is built from the ground-up for [[concurrent programming>>http://en.wikipedia.org/wiki/Concurrent_computing]]- a methodology that can take advantage of these modern multi-coreprocessors.1 +Given that todays processors ship with dual or quad cores and server processors ship with between 8 to 32 cores, languages like Java, Ruby, Groovy and Python are struggling to keep up. 2 2 3 - IfyouuseScalaforaconcurrent programming application,thechancesarethatyou'reusing Scala [[Actors>>http://en.wikipedia.org/wiki/Actor_model]]todothat.3 +Scala, as its name suggests is built from the ground-up for concurrent programming - a methodology that can take advantage of these modern multi-core processors. 4 4 5 - {{info title="Scala Actors"}}5 +If you use Scala for a concurrent programming, the chances are that you're using Scala Actor to do that. 6 6 7 -Concurrent programming in Scala is based on *Actors* (with an inbox) - a simple metaphor that is analogous to *Message Queues*. 8 - 9 -{{/info}} 10 - 11 11 == Using Scala Actors with EOF == 12 12 13 -EOF being notoriously single-threaded, is incredibly unsuitable for use with Scala Actors: 9 +EOF being notoriously single-threaded, is incredibly unsuitable for use by Scala Actors. 10 +Instead you may still use EOF but only to execute SQL directly. 14 14 15 -* EOs are mutable objects and as such they cannot be passed safely to Scala Actors 16 -* Fetching and updating EOs from within Scala Actors can cause [[deadlocks>>http://en.wikipedia.org/wiki/Deadlock]] with the WebObjects application 17 - 18 -Instead you can still use EOF but in a limited fashion - only to execute SQL. 19 - 20 20 === Using EOAccess to execute SQL === 21 21 22 -Use Wonder API: [[ERXEOAccessUtilities.evaluateSQLWithEntityNamed()>>http://webobjects.mdimension.com/hudson/job/Wonder53/javadoc/er/extensions/eof/ERXEOAccessUtilities.html#evaluateSQLWithEntity(com.webobjects.eocontrol.EOEditingContext,%20com.webobjects.eoaccess.EOEntity,%20java.lang.String)]] 23 - 24 -==== Caveats ==== 25 - 26 -If you're updating the state of EOs directly in the database using SQL from Scala Actors, you will subsequently need to refresh/refetch these EOs for the WebObjects application to see those changes. 27 - 28 -== EOF Alternatives == 29 - 30 -You may also manipulate the database from outside the EOF stack. 31 - 32 -=== Squeryl === 33 - 34 -[[Squeryl>>http://max-l.github.com/Squeryl/index.html]] is a strongly typed and declarative [[Domain-specific language>>http://en.wikipedia.org/wiki/Domain-specific_language]] for manipulating database objects from within the Scala language.{{quote}}{{/quote}} 35 - 36 -You may update the database from Scala Actors using Squeryl instead of using EOF. The advantage here is that you may access the database concurrently avoiding the single-threaded EOF bottleneck in your application. 37 - 38 -However the same caveat applies - you will need to refresh EOs in the EOF stack for the WebObjects application to reflect the changes made by Squeryl. 14 +Using Wonder API: [[ERXEOAccessUtilities.evaluateSQLWithEntityNamed()>>http://webobjects.mdimension.com/hudson/job/Wonder53/javadoc/er/extensions/eof/ERXEOAccessUtilities.html#evaluateSQLWithEntity(com.webobjects.eocontrol.EOEditingContext,%20com.webobjects.eoaccess.EOEntity,%20java.lang.String)]]