Re: [fpc-pascal] Call function in shared library from multiple threads

2017-04-12 Thread fredvs
>> TDummyThread.Create(True) > Huh, I have memory leak with this. > Should it not be: --> TDummyThread.Create(false) ? (because with this, no > memory leak) Hello. Sorry to come back with this but without answer I am still full of doubt. Is TDummyThread.Create(True) wanted and so the

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-04-02 Thread fredvs
> TDummyThread.Create(True) Huh, I have memory leak with this. Should it not be: --> TDummyThread.Create(false) ? (because with this, no memory leak) Fre;D - Many thanks ;-) -- View this message in context:

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-31 Thread silvioprog
On Fri, Mar 31, 2017 at 1:15 PM, Henry Vermaak wrote: > On Fri, Mar 31, 2017 at 08:42:24AM -0700, fredvs wrote: > > > Z:\home\fred\uos\examples\uos.pas(7438,29) Warning: (4046) > Constructing a > > > class "TThread" with abstract method "Execute" > > > > Huh, is it Is it

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-31 Thread fredvs
Michael Van Canneyt wrote > Best is probably: > > Type >TDummyThread = Class(TThread) >public > procedure execute; override; >end; > > procedure TDummyThread.Execute; > > begin >FreeOnTerminate:=True; >Terminate; > end; > > > begin >TDummyThread.Create(True) >

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-31 Thread Henry Vermaak
On Fri, Mar 31, 2017 at 08:42:24AM -0700, fredvs wrote: > > Z:\home\fred\uos\examples\uos.pas(7438,29) Warning: (4046) Constructing a > > class "TThread" with abstract method "Execute" > > Huh, is it Is it serious doctor? I use this: function DummyThread(param: pointer): ptrint; begin Result

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-31 Thread Michael Van Canneyt
On Fri, 31 Mar 2017, fredvs wrote: Hello. Michael Van Canneyt wrote To fix that, you can do the following. In the library startup code, create a dummy thread. This will initialize the threads mechanism: with TThread.Create(False) do end. I use this for initialize my libraries:

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-31 Thread fredvs
Hello. Michael Van Canneyt wrote > To fix that, you can do the following. > In the library startup code, create a dummy thread. > This will initialize the threads mechanism: > >with TThread.Create(False) do > > end. I use this for initialize my libraries: With TThread.Create(False) do

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-31 Thread Krzysztof
Thanks a lot! Seems to working fine now ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org http://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-31 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, Michael Van Canneyt wrote: On Thu, 30 Mar 2017, Krzysztof wrote: 2017-03-30 15:19 GMT+02:00 Michael Van Canneyt Nevertheless, that should work. I've used it in multi-threaded apache modules. Well it doesn't work or fpjson module is not

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, Krzysztof wrote: 2017-03-30 15:19 GMT+02:00 Michael Van Canneyt Nevertheless, that should work. I've used it in multi-threaded apache modules. Well it doesn't work or fpjson module is not thread safe in this case. You can test it by

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Krzysztof
2017-03-30 15:19 GMT+02:00 Michael Van Canneyt > > > Nevertheless, that should work. > > I've used it in multi-threaded apache modules. > Well it doesn't work or fpjson module is not thread safe in this case. You can test it by yourself with attached demo (first post).

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, Michael Van Canneyt wrote: On Thu, 30 Mar 2017, Krzysztof wrote: Yes, I'm aware of cthreads and tested it too (without it also critical sections don't work) but it doesn't help with attached examples. Still same errors in logs Nevertheless, that should work. I

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Michael Van Canneyt
On Thu, 30 Mar 2017, Krzysztof wrote: Yes, I'm aware of cthreads and tested it too (without it also critical sections don't work) but it doesn't help with attached examples. Still same errors in logs Nevertheless, that should work. I've used it in multi-threaded apache modules. Michael.

Re: [fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Krzysztof
Yes, I'm aware of cthreads and tested it too (without it also critical sections don't work) but it doesn't help with attached examples. Still same errors in logs ___ fpc-pascal maillist - fpc-pascal@lists.freepascal.org

[fpc-pascal] Call function in shared library from multiple threads

2017-03-30 Thread Krzysztof
Hi, I'm wondering if shared libraries (on Linux) support call exported function from multiple threads. I made small demo. Threads send JSON PChar into shared lib function which parse it and log in syslog. No global vars, everything locally in function. But even that I'm getting random errors