You might want to try to trace the thread name as well ...

On Nov 29, 6:49 pm, Marius <[email protected]> wrote:
> In your code in what conditions  joinOtherOrders gets called ?
>
> Br's,
> Marius
>
> On Nov 29, 6:18 pm, Hannes <[email protected]> wrote:
>
> > Hi Tim,> Hannes,
>
> > > Firstly, I really, really wouldn't write your code like that...
>
> > > Things of note:
> > > - two defs inside defs... you usually wouldnt do this without a good 
> > > reason (like SHtml.submit(whatever _))
>
> > The two defs only make sence together, that's why I put them together in
> > one def. I think that's encapsulation...> - dont use while loops. period. 
> > you have a List[T], use foreach if you have a unit operation
>
> > Yeah, that's true. But the problem is, that my logic requires to stop
> > the iteration at some point. How I gonna do that with a foreach construct?> 
> > def joinAll(orders: List[LimitOrder]): Unit =
> > >   orders.foreach(order => {
> > >     // your logic here
> > >   })
>
> > > You should look to remove a lot of that boiler plate... its looks very 
> > > javaish and mutable. Generally speaking, scala programmers avoid mutable 
> > > state like one would avoid bubonic plague.
>
> > Your totally right! Its mutable, cause its changing the state of my
> > objects. But that's necessary at this point.> Before worrying about the 
> > errors, id change your code, then take another look... its almost certainly 
> > this bad organisation causing the issues.
>
> > I agree with you, that this is not the most beautiful code I every saw,
> > but I believe that the things you mentioned are not interfering with the
> > problem I'm facing. At least not because of a while-loop and some inner
> > local defs.
>
> > > Cheers, Tim
>
> > thanks.
>
> > > On 29 Nov 2009, at 15:24, Hannes wrote:
>
> > >> Hey Lifters,
>
> > >> I've some really strange things going on here. Please consider this
> > >> method definition. I've put alot of print "debug" statements between
> > >> other statements. There's a while-loop that only starts, when the given
> > >> list (orders) is not empty. It stops when "done" is set to true. So far,
> > >> so good. Than, have a look at the Lift output. I put in a comment,
> > >> pointing out where the program runs into the while loop.
>
> > >> What really shocks me, are these print statements :
>
> > >> before done=false                                                        
> > >>                                       
> > >> after done=true                                                          
> > >>                                       
> > >> i += 1                                                                   
> > >>                                        
> > >> outside while                                                            
> > >>                                       
> > >> INFO - Service request (GET) / took 121 Milliseconds                     
> > >>                                        
> > >> start of joinAll!                                                        
> > >>       
>
> > >> The loop ends with "outside while" and than the method gets called again
> > >> immediately! But who calls it? I don't....
>
> > >> Any ideas?
>
> > >> thanks.
>
> > >> ---------------------------- method definition
> > >> --------------------------------------------------------------------------
>
> > >> def joinOtherOrders: Unit = {
>
> > >>        def joinAll(orders: List[LimitOrder]) = {
>
> > >>            println("start of joinAll!")
>
> > >>            var done = false
>
> > >>            var i = 0
>
> > >>            while (!orders.isEmpty && !done) {
>
> > >>                println("i=" + i + ", " + "orders.isEmpty=" + 
> > >> orders.isEmpty + ", " + "done=" + done)
>
> > >>                if (this.lots.is == orders(i).lots.is){
>
> > >>                    println("case-1")
>
> > >>                    println("this=" + this + ", orders(i)=" + orders(i))
>
> > >>                    this.open(orders(i))
>
> > >>                    done = true
>
> > >>                }
>
> > >>                if (this.lots.is < orders(i).lots.is){
>
> > >>                    println("case-2")
>
> > >>                    println("this=" + this + ", orders(i)=" + orders(i))
>
> > >>                    orders(i).reduceLots(this.lots.is)
>
> > >>                    val newOrder = orders(i).cloneWith(this.lots.is)
>
> > >>                    newOrder.save
>
> > >>                    this.open(newOrder)
>
> > >>                    println("before done=" + done)
>
> > >>                    done = true
>
> > >>                    println("after done=" + done)
>
> > >>                }
>
> > >>                if (this.lots.is > orders(i).lots.is){
>
> > >>                    println("case-3")
>
> > >>                    println("this=" + this + ", orders(i)=" + orders(i))
>
> > >>                    this.reduceLots(orders(i).lots.is)
>
> > >>                    val newOrder = this.cloneWith(orders(i).lots.is)
>
> > >>                    newOrder.save
>
> > >>                    newOrder.open(orders(i))
>
> > >>                }
>
> > >>                i += 1
>
> > >>                println("i += 1")
>
> > >>            }
>
> > >>            println("outside while")
>
> > >>        }
>
> > >>        def findLimitOrdersById: List[LimitOrder]  =
>
> > >>            this.findCandidates.map(x => LimitOrderMetaObj.findAll(
>
> > >>                    By(LimitOrderMetaObj.id, x)).head)
>
> > >>        joinAll(findLimitOrdersById)
>
> > >>    }
>
> > >> ---------- Lift Output 
> > >> -------------------------------------------------------------------------------
>
> > >> [INFO] Started Jetty Server                                              
> > >>                                       
> > >> [INFO] Starting scanner at interval of 5 seconds.                        
> > >>                                       
> > >> INFO - Service request (GET) /comet_request/54834680365/y7kybsmuyv1g 
> > >> took 64 Milliseconds                      
> > >> INFO - Service request (GET) /comet_request/85319966940/y7kybsmuyv1g 
> > >> took 23 Milliseconds                      
> > >> INFO - Service request (GET) /favicon.ico took 86 Milliseconds           
> > >>                                        
> > >> INFO - Service request (GET) /comet_request/41521581405/y7kybsmuyv1g 
> > >> took 48 Milliseconds                      
> > >> INFO - Service request (GET) /comet_request/93176242746/y7kybsmuyv1g 
> > >> took 7 Milliseconds                        
> > >> INFO - Service request (GET) /favicon.ico took 38 Milliseconds           
> > >>                                        
> > >> INFO - Service request (GET) /favicon.ico took 5 Milliseconds            
> > >>                                       
> > >> INFO - Service request (GET) / took 551 Milliseconds                     
> > >>                                        
> > >> INFO - Service request (GET) /comet_request/81361316835/y7kybsmuyv1g 
> > >> took 9 Milliseconds                        
> > >> INFO - Service request (GET) /favicon.ico took 16 Milliseconds           
> > >>                                        
> > >> INFO - Service request (GET) / took 61 Milliseconds                      
> > >>                                       
> > >> INFO - Service request (GET) /comet_request/76898140873/y7kybsmuyv1g 
> > >> took 30 Milliseconds                      
> > >> INFO - Service request (GET) /comet_request/e8jesgmo10oq/cometAjax.js 
> > >> took 14 Milliseconds                      
> > >> INFO - Service request (GET) / took 354 Milliseconds                     
> > >>                                        
> > >> INFO - Service request (GET) / took 734 Milliseconds                     
> > >>                                        
> > >> INFO - Service request (GET) / took 484 Milliseconds                     
> > >>                                        
> > >> INFO - Service request (GET) /images/ajax-loader.gif took 7 Milliseconds 
> > >>                                        
> > >> INFO - Service request (GET) /favicon.ico took 4 Milliseconds            
> > >>                                       
> > >> INFO - Service request (GET) /comet_request/78026241833/e8jesgmo10oq 
> > >> took 55 Milliseconds                      
> > >> INFO - Service request (GET) /comet_request/28225538857/e8jesgmo10oq 
> > >> took 600 Milliseconds                      
> > >> INFO - Service request (GET) /user_mgt/sign_up took 711 Milliseconds     
> > >>                                        
> > >> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds 
> > >>                                        
> > >> INFO - Service request (GET) /user_mgt/login took 38 Milliseconds        
> > >>                                       
> > >> INFO - Service request (GET) /images/ajax-loader.gif took 2 Milliseconds 
> > >>                                        
> > >> INFO - Service request (POST) /user_mgt/login took 122 Milliseconds      
> > >>                                       
> > >> INFO - Service request (GET) / took 93 Milliseconds                      
> > >>                                       
> > >> INFO - Service request (GET)
>
> ...
>
> read more »

--

You received this message because you are subscribed to the Google Groups 
"Lift" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/liftweb?hl=en.


Reply via email to