Calling external support functions from other threads

Andre Garzia andre at andregarzia.com
Tue Jul 17 22:21:09 EDT 2012


I can only speak for external sdk for mac os x and linux where if you try
SendCardMessage from a different thread you're dead.

There is an odd scenario where the first subthread is able to call
SendCardMessage but ones spawned after that are not.

I have an webserver external that uses a pool of pthreads to handle HTTP
requests and you can bind a URL to a LiveCode handler so that when a HTTP
request comes asking for that URL, it should call SendCardMessage and use
the result as the response. Unfortunately, the external does not work
because I can't really call SendCardMessage from the other threads. I would
need to set some unix socket or pipe to communicate with the main thread
and send the message from there. I am yet to solve this so if you ever come
up with a solution please let me know. I know very little about IPC.

Cheers
andre

On Tue, Jul 17, 2012 at 10:11 PM, Dar Scott <dsc at swcp.com> wrote:

> The wisdom that I have inherited is that all support functions in the
> externals library must be called only from an external function or command
> called from LiveCode.  That is, they are not thread safe.  Others and I
> have repeated this.
>
> If an external has multiple threads then some thread-save method is needed
> to move data to where it can be picked up, or it is converted to an event
> that LiveCode handles.
>
> In particular SendCardMessage should not be called from a separate thread.
>
> However, I have recently seen external source made public that does
> include SendCardMessage called from another thread.
>
> So, I wonder.  Am I wrong?
>
> (I like the iOS external SDK.  It has nice methods for 'send' and 'wait'.
>  I can 'send' a message from any thread at any time.  Also, you can figure
> from the documentation, and maybe the header file, when you can do what
> when.)
>
> Dar
>
>
> ---------------------------
> Dar Scott
> dba
> Dar Scott Consulting
> 8637 Horacio Place NE
> Albuquerque, NM 87111
>
> Lab, home, office phone: +1 505 299 9497
> For Skype and fax, please contact.
> dsc at swcp.com
>
> Computer programming and tinkering,
> usually in supporting those developing in
> LiveCode--typically by making LiveCode
> controls, libraries and externals, and
> sometimes by writing associated
> microcontroller firmware.
> ---------------------------
>
>
>
>
>
> _______________________________________________
> use-livecode mailing list
> use-livecode at lists.runrev.com
> Please visit this url to subscribe, unsubscribe and manage your
> subscription preferences:
> http://lists.runrev.com/mailman/listinfo/use-livecode
>



-- 
http://www.andregarzia.com -- All We Do Is Code.
http://fon.nu -- minimalist url shortening service.



More information about the use-livecode mailing list