Hi Andrew,

I don't really understand your question as well as I'd like to (in 
particular, I don't understand the difference between a "callback" and 
any other sort of procedure; as well as other confusions) So this might 
be bunk advice, but here it is...

Have you considered making your own thread function wrapper that could 
duplicate the functionality you need?

type
  thread_param_and_callback_func = record
    thread_func : function (p : pointer) : ptrint;  // as required
    thread_param : pointer;  // the parameter to the main thread func
    callback_proc : procedure (...);
    callback_param : ???;
    end;
  p_thread_param_and_callback_func = ^thread_param_and_callback_func;

function thread_proc_wrapper (p : pointer) : ptrint;
begin
  with thread_param_and_callback_func (p^) do begin
    thread_func (thread_param);
    callback_proc (callback_param);
    end;
end;

I've only made one multithreaded program at this point, but it was a 
huge success, and I used something similar to this-- a thread handling 
function that would repeatedly request tasks and execute them, until 
the tasks were all complete. (I added a repeat loop...)

Hope this helps... (or inspires you to think of something that will 
work :)

~David.


On Thu 8 Oct 2009, Andrew Brunner wrote:
> Hi there,
> 
> I've got a unit I'm porting from Windows to Linux and I came across a
> QueueUserAPC (Kernel32 Windows) I make to add a callback method that
> gets executed by the thread I added this to.
> 
> function QueueUserAPC(Callback: Pointer; hThread: THandle;
> dwData:DWORD): boolean; stdcall;
> 
> When the Thread gets around to it, it processes the callback function
> I passed in during the queue call.
> 
> Judging by the performance of this method I would say that the Windows
> Kernel maintains a queue of events to process for each thread.  And
> this function allows me to attach a callback to that queue so I can
> allocate memory within that stack rather than the stack of the calling
> thread.  This feature is important as I want to keep memory allocation
> to specific threads.
> 
> Does Threading under Linux have anything like this?  Have any of you
> done anything like this under *nix?
> 
> Thanks for any feedback.
> _______________________________________________
> fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
> http://lists.freepascal.org/mailman/listinfo/fpc-pascal
> 



_______________________________________________
fpc-pascal maillist  -  fpc-pascal@lists.freepascal.org
http://lists.freepascal.org/mailman/listinfo/fpc-pascal

Reply via email to