dcsimg
C++ Communication. Can I call a C++ method of a thread from a java thread, so I only have to call the library for initialisation?
1 posts in topic
Flat View  Flat View
TOPIC ACTIONS:
 

Posted By:   Hans_Dollen
Posted On:   Monday, March 10, 2003 06:59 AM

Hi, I'm building an application which uses C++ Communication threads. I have 10 java threads which are of the same instance. I 've also 10 C++ threads, which send the data. The working is as follows: You call the Send method of the java object, which passes the data to the library. the library passes the data to the specific (C++) thread by calling its method Send. But for all threads the data goes through the library, and for speed and concurrency, I want to have it directly to the specific thread. Can the java object obtain something from the C++ thread so the function can be called directly? Or is there another solution... Hans (The Netherlands)    More>>

Hi,


I'm building an application which uses C++ Communication threads. I have 10 java threads which are of the same instance. I 've also 10 C++ threads, which send the data.


The working is as follows: You call the Send method of the java object, which passes the data to the library. the library
passes the data to the specific (C++) thread by calling its method Send.


But for all threads the data goes through the library, and for speed and concurrency, I want to have it directly to the specific thread.


Can the java object obtain something from the C++ thread so the function can be called directly? Or is there another solution...


Hans (The Netherlands)


For now it looks like this:


			
Java Threads: 1 2 3 4 5 .. 10
| | | | |
|/ /
/ /
/ /
/
C++ library(Send)|
/
/
/ /
/ / |
| | | | |
C++ Threads : 1 2 3 4 5 .. 10
   <<Less

Re: C++ Communication. Can I call a C++ method of a thread from a java thread, so I only have to call the library for initialisation?

Posted By:   Christopher_Schultz  
Posted On:   Friday, April 4, 2003 01:41 PM

Hans,



Consider changing your model. What if your C++ library (containing the send function) is thread-ignorant? You could have your send function enqueue the messages in a threadsafe (P-threads, win32_threads, etc.) way. Then, your C++ threads could dequeue the messages also in a threadsafe way.



This way, you run some kind of init method to start the threads initially, and then just put data into that queue.



Then, you don't have to worry about multiplexing data from Java threads into C++ threads.<,p>

Hope that helps,

-chris
About | Sitemap | Contact