Changes between Version 8 and Version 9 of BlockObjects


Ignore:
Timestamp:
Aug 13, 2011 5:48:05 AM (3 years ago)
Author:
chak
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • BlockObjects

    v8 v9  
    4141== Example: returning a C block == 
    4242 
    43 Conversely, a C block object can be used as a function in Haskell.  Assume the declaration 
     43Conversely, a C block object can be used as a function in Haskell.  Given the following C prototype 
     44{{{ 
     45typedef void (^callback_t)(handle); 
     46 
     47callback_t  
     48get_callback (void); 
     49}}} 
     50assume the FFI declaration 
    4451{{{ 
    4552foreign import ccall get_callback :: IO (Handle -> IO ()) 
     53  -- where 'Handle' is a new type of some C pointer type 
    4654}}} 
     55We might use the imported C function as follows: 
     56{{{ 
     57do 
     58  callback <- get_callback 
     59  callback myHandle 
     60}}} 
     61'''TODO:''' Is there a better example? Something from an official API? 
    4762 
    48 {{{ 
    49 use it 
    50 }}} 
     63== Storage management == 
     64 
     65'''TODO:''' How do we recover a Haskell function's storage once it has been turned into a block object and passed to a C function?  (NB: the environment of the function may hold on to large data structures, which will only be freed once the function is freed.) 
     66 
     67When we marshal a C block object into a Haskell function, we need to ensure that the Haskell storage manager releases the block object once the Haskell land function becomes unreachable in the Haskell heap. 
    5168 
    5269== The gory details == 
    5370 
    54 The following subpages provide details on implementing this functionality. 
     71The following subpages provide details on implementing this functionality.  '''(The following three subpages are forthcoming.) 
    5572 * [wiki:BlockObjects/Specification] (pure versus impure; corner cases `void (^foo) (void)` in the pure cases) 
    5673 * [wiki:BlockObjects/FakingIt]