Changeset 5564


Ignore:
Timestamp:
Nov 28, 2006, 3:12:52 PM (18 years ago)
Author:
Gary Byers
Message:

Wrap a (primitive) WITH-AUTORELEASE-POOL around the code which detaches
the dummy NSThread.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/ccl/examples/objc-runtime.lisp

    r5383 r5564  
    296296  ;; multitheaded.  (A lot of other things, including
    297297  ;; the ObjC runtime, seem to have already noticed.)
    298   (with-cstrs ((class-name "NSThread")
    299                (message-selector-name "detachNewThreadSelector:toTarget:withObject:")
    300                (exit-selector-name "exit"))
    301     (let* ((nsthread-class (#_objc_lookUpClass class-name))
    302            (message-selector (#_sel_getUid message-selector-name))
    303            (exit-selector (#_sel_getUid exit-selector-name)))
    304       (#_objc_msgSend nsthread-class message-selector
    305                       :address exit-selector
    306                       :address nsthread-class
    307                       :address (%null-ptr))
     298  (with-cstrs ((thread-class-name "NSThread")
     299               (pool-class-name "NSAutoreleasePool")
     300               (thread-message-selector-name "detachNewThreadSelector:toTarget:withObject:")
     301               (exit-selector-name "exit")
     302               (alloc-selector-name "alloc")
     303               (init-selector-name "init")
     304               (release-selector-name "release"))
     305    (let* ((nsthread-class (#_objc_lookUpClass thread-class-name))
     306           (pool-class (#_objc_lookUpClass pool-class-name))
     307           (thread-message-selector (#_sel_getUid thread-message-selector-name))
     308           (exit-selector (#_sel_getUid exit-selector-name))
     309           (alloc-selector (#_sel_getUid alloc-selector-name))
     310           (init-selector (#_sel_getUid init-selector-name))
     311           (release-selector (#_sel_getUid release-selector-name))
     312           (pool (#_objc_msgSend
     313                  (#_objc_msgSend pool-class
     314                                  alloc-selector)
     315                  init-selector)))
     316      (unwind-protect
     317           (#_objc_msgSend nsthread-class thread-message-selector
     318                           :address exit-selector
     319                           :address nsthread-class
     320                           :address (%null-ptr))
     321        (#_objc_msgSend pool release-selector))
    308322      nil)))
    309323
Note: See TracChangeset for help on using the changeset viewer.