How to do inter-thread communication

Discussions about using 3rd party extension with OpenOffice.org

How to do inter-thread communication

Postby LRN » Mon Oct 07, 2019 4:19 pm

Let's say that i need to do something time-consuming. The normal way to go about it is to create a thread and make it do the work, then report back with the result.

Creating a thread is not difficult. The real question is how to communicate the result *back* from the worker thread to the main thread of my office extension. Extensions, AFAIK, do not run an event loop, so there might not even *be* a "main thread" of an extension at a given moment, just the office doing its thing. I thought that maybe i could register an XJobExecutor and then use the XAsyncJob to queue a job from the worker thread to be executed in the main thread - but it's difficult to find examples of something like this, and the SDK is almost completely silent on the subject of thread-safety.

This is compounded by the fact that i'm using Python (so i will probably need to use *processes* instead of threads (thank you, GIL!), which adds a whole new set of problems with regard to communication), and Python examples are almost non-existent (SDK has 1 (/one/) Python component example).
LibreOffice 3.2 NT 6.1.7601
LRN
 
Posts: 2
Joined: Tue May 10, 2011 10:55 am

Re: How to do inter-thread communication

Postby sasa » Mon Oct 07, 2019 5:17 pm

Hi,

you can try solution in this thread, tested in dialogs and sidebar extension:
https://forum.openoffice.org/en/forum/viewtopic.php?f=20&t=89503

Best
LibreOffice 5.2 on Xubuntu 16.04
sasa
 
Posts: 7
Joined: Wed Feb 08, 2017 12:54 am


Return to Extensions

Who is online

Users browsing this forum: No registered users and 1 guest