www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Multi-threading how-to

reply solidstate1991 <laszloszeremi outlook.com> writes:
I decided to write a shared library for OSC in D despite the lack 
of popularity.

I decided to add a functionality that if multiple programs use 
the same instance of the library on the same computer, the 
messages will be passed directly instead of via networking.

Unfortunately we barely touched multi-threading in college. Some 
suggestions?
Aug 31 2016
parent reply Cauterite <cauterite gmail.com> writes:
On Wednesday, 31 August 2016 at 17:37:25 UTC, solidstate1991 
wrote:
 I decided to add a functionality that if multiple programs use 
 the same instance of the library on the same computer, the 
 messages will be passed directly instead of via networking.
What you're describing here is not actually multi-threading, it's multi-process…ing. The keyword you're looking for is "inter-process communication". You have a huge range of possible options for implementing this. Your decision would depend on your operating system, your existing implementation with sockets, and desired performance. My suggestion: try just using sockets between processes on the same PC. You might not even need to add any new code to support this method, and it might be faster than you'd expect.
Aug 31 2016
parent "H. S. Teoh via Digitalmars-d-learn" <digitalmars-d-learn puremagic.com> writes:
On Wed, Aug 31, 2016 at 05:53:27PM +0000, Cauterite via Digitalmars-d-learn
wrote:
 On Wednesday, 31 August 2016 at 17:37:25 UTC, solidstate1991 wrote:
 I decided to add a functionality that if multiple programs use the
 same instance of the library on the same computer, the messages will
 be passed directly instead of via networking.
What you're describing here is not actually multi-threading, it's multi-process…ing. The keyword you're looking for is "inter-process communication". You have a huge range of possible options for implementing this. Your decision would depend on your operating system, your existing implementation with sockets, and desired performance. My suggestion: try just using sockets between processes on the same PC. You might not even need to add any new code to support this method, and it might be faster than you'd expect.
[...] If you're on Posix (Linux, *nix, etc.), you could also use pipes, which may be easier to setup. T -- A linguistics professor was lecturing to his class one day. "In English," he said, "A double negative forms a positive. In some languages, though, such as Russian, a double negative is still a negative. However, there is no language wherein a double positive can form a negative." A voice from the back of the room piped up, "Yeah, yeah."
Aug 31 2016