Concurrency Problems

Forum for development in the C++ programming language.

Concurrency Problems

Postby ignaciofallas » 15 Jul 2015, 10:54

Hi,

I'm trying to connect two eyetribes to the same program I'm building. I have found that it fails for memory violations when this line: "if (gaze_data.state & gtl::GazeData::GD_STATE_TRACKING_GAZE)" is executed. What I can see is that GazeData contains single structures that in case of creating two instances of the GazeListener class will be used/accessed for those two instances, causing the system to fail. Please correct me if I'm wrong here, but so far the only solution I can see is to create another class that stores this information allocating this memory separately for each instance of a GazeListener, but this is a mayor change in the sdk.
I was wondering if you have some help here, any other solution or even some example or guidance. I would be very thankful with any help.
ignaciofallas
 
Posts: 7
Joined: 24 Jun 2015, 14:19

Re: Concurrency Problems

Postby Anders » 15 Jul 2015, 12:07

I'm trying to connect two eyetribes to the same program I'm building. I have found that it fails for memory violations when this line: "if (gaze_data.state & gtl::GazeData::GD_STATE_TRACKING_GAZE)" is executed. What I can see is that GazeData contains single structures that in case of creating two instances of the GazeListener class will be used/accessed for those two instances, causing the system to fail. Please correct me if I'm wrong here, but so far the only solution I can see is to create another class that stores this information allocating this memory separately for each instance of a GazeListener, but this is a mayor change in the sdk.
I was wondering if you have some help here, any other solution or even some example or guidance. I would be very thankful with any help.


In order to help you I first need to understand the problem you have.

Are you saying that you have two TET trackers connected to the same computer? Or are you saying that you have two instances of the TET C++ SDK running at the same time?
Anders
 
Posts: 124
Joined: 29 Oct 2013, 16:23

Re: Concurrency Problems

Postby ignaciofallas » 15 Jul 2015, 12:17

Hi again,

I have two TET trackers connected in the same computer with the respective servers for each tracker at different ports. Now I want to connect using the sdk to both servers at the same time and get the data from each of them. I'm having memory violations when getting the gazedata, and I guess this is due to the structures of the file "gazeapi_types.h" which are single and probably both instances of the sdk are using at the same time.

Best,
ignaciofallas
 
Posts: 7
Joined: 24 Jun 2015, 14:19

Re: Concurrency Problems

Postby Anders » 15 Jul 2015, 12:54

I have two TET trackers connected in the same computer with the respective servers for each tracker at different ports. Now I want to connect using the sdk to both servers at the same time and get the data from each of them. I'm having memory violations when getting the gazedata, and I guess this is due to the structures of the file "gazeapi_types.h" which are single and probably both instances of the sdk are using at the same time.


Well then I am afraid that is your problem. The Eye Tribe Dev Kit do not officially support several trackers connected to one machine.

That being said, have you made sure that the two SDKs instances use each their ports when instantiated?
Anders
 
Posts: 124
Joined: 29 Oct 2013, 16:23

Re: Concurrency Problems

Postby ignaciofallas » 15 Jul 2015, 13:39

Yes I'm completely sure. Is good to know the official answer then. If some day you want to support concurrency I'll be glad to hear it.

Thanks again
ignaciofallas
 
Posts: 7
Joined: 24 Jun 2015, 14:19

Re: Concurrency Problems

Postby Anders » 15 Jul 2015, 13:49

Yes I'm completely sure. Is good to know the official answer then. If some day you want to support concurrency I'll be glad to hear it.


I'll let our C++ team know about this, but since this is not officially supported, I cannot promise that it is something we'll look into in a near future (if ever).

Should you find a solution to the SDK issue, feel free to contribute it to the GitHub project.
Anders
 
Posts: 124
Joined: 29 Oct 2013, 16:23

Re: Concurrency Problems

Postby ignaciofallas » 15 Jul 2015, 14:05

Thanks, it would be great if in such a case you keep me notified. I'll myself try to come up with a solution in the near future, because I need this soon, if I find the solution I'll let you know.


Best regards,
ignaciofallas
 
Posts: 7
Joined: 24 Jun 2015, 14:19

Re: Concurrency Problems

Postby Micky » 22 Jul 2015, 18:10

It is possible to have multiple trackers connected to the same system. Just remember to assign different tcp ports for each instance (--port, or in config) along with the device index (--device, or in config), e.g. if two TheEyeTracker devices are connected start two servers like:
Code: Select all
1: EyeTribe --device=0 --port=6555  (default)
2: EyeTribe --device=1 --port=6556

We have a boost synchronization bug in the C++ SDK that basically prevents you from using multiple GazeApi objects within the same process. It is often shown as memory issues at different places. We have fixed this with the next release of the SDK. In the mean time you can solve the issue by adding
Code: Select all
#define BOOST_SPIRIT_THREADSAFE

in the C++ SDK header/source files before including any boost/property_tree headers. Some details about the same problem can be found here: http://stackoverflow.com/questions/8156948/is-boostproperty-treeptree-thread-safe

The following C++ code sample should then work without the crash:
Code: Select all
  GazeListenerObj gaze; // derived from gtl::IGazeListener

  gtl::GazeApi api0;
  api0.add_listener( gaze );
  api0.connect( 6555 );

  gtl::GazeApi api1;
  api1.add_listener( gaze );
  api1.connect( 6556 );
User avatar
Micky
 
Posts: 12
Joined: 05 Jan 2015, 16:23


Return to C++



cron