1. -- parent script "CurlDetacher"
  2.  
  3. --****************************************************************************
  4. -- @file    Curl Callback Detach Class
  5. -- @author  Valentin Schmidt
  6. --****************************************************************************
  7.  
  8. property ancestor
  9.  
  10. property _method
  11. property _receiver
  12. property _ch
  13. property _customData
  14. property _res
  15.  
  16. ----------------------------------------
  17. -- @constructor
  18. ----------------------------------------
  19. on new (me, method, receiver, ch, customData)
  20.   me._method = method
  21.   me._receiver = receiver
  22.   me._ch = ch
  23.   me._customData = customData
  24.   me.ancestor = timeout().new(string(me), 0, #_call, me)
  25.   return me
  26. end
  27.  
  28. ----------------------------------------
  29. -- use 1 ms single-shot timeout to create a new thread,
  30. -- so scripting errors in callbacks don't fail silently
  31. ----------------------------------------
  32. on _detach (me, res)
  33.   me._res = res
  34.   me.period = 1
  35. end
  36.  
  37. ----------------------------------------
  38. -- we are detached from original thread, now call original callback
  39. ----------------------------------------
  40. on _call (me, res)
  41.   me.forget()
  42.   call(me._method, me._receiver, me._res, me._ch, me._customData)
  43. end
  44.  
[raw code]