On Tue, 04 Aug 2009 14:54:51 -0700, Christoph Senjak  
<[email protected]> wrote:

>
>> Elliott mentioned that the "cannot lock surface" is also a problem with
>> CCL for OS X.
>
> When changing swank:*communication-style* to :fd-handler (in the
> swank.lisp-file), also mandelbrot and the other examples, as well as
> my code, work perfectly under SBCL. So there must be some problem with
> swank's preferred communication style, which is :spawn.

(defmacro with-locked-surface ((var &optional surface)
                                &body body)
   (let ((body-value (gensym "body-value-")))
     `(let ((,body-value nil))
        (with-surface (,var ,surface ,nil)
         (unwind-protect
              (progn (when (must-lock? ,var)
                       (when (/= (sdl-cffi::sdl-Lock-Surface ,var) 0)
                         (error "Cannot lock surface")))
                     (setf ,body-value (progn ,@body))
                      (Sdl-Cffi::Sdl-Unlock-Surface ,var)))
         ,body-value))))


The above macro handles surface locking. What is happening is that  
must-lock? returns T but the subsequent call to sdl-lock-surface fails.

> http://common-lisp.net/project/slime/doc/html/Communication-style.html#Communication-style
> sais: "This style uses multiprocessing support in the Lisp system to
> execute each request in a separate thread. This style has similar
> properties to :SIGIO, but it does not use signals and all requests
> issued by Emacs can be executed in parallel."

The threading support for SBCL in OS X is stated as being experimental.

http://www.sbcl.org/manual/Threading.html

But I'm not sure how this could cause the surface lock to fail as Slime is  
spawning a single thread to run the example. It is not like multiple  
threads are spawned.

> Do you maybe use some non-threadsafe operations?

lispbuilder-sdl does not provide any additional support for multithreading  
above what is provided by the SDL library. And the SDL library provides no  
support at all. Access to all surface and drawing functions in SDL must be  
 from the same thread.

- Luke
_______________________________________________
application-builder mailing list
[email protected]
http://www.lispniks.com/mailman/listinfo/application-builder

Reply via email to