programming question

HouseBot Plugin Development Discussions.
Post Reply
peter
Member
Posts: 35
Joined: Wed May 31, 2006 3:51 am
Location: Berlin , GER

programming question

Post by peter »

Scott, a little question:
Is it legal to put a new property change request to the queue while a current call of the devices' run-function is not yet finished? (reentrant problems)

In my application, the run-function triggers a separate thread with an event and the separate thread calls subsequently a few changerequests. This could happen before the end of the origininal run-function-call has been finished.

I guess thats the reason I've got some trouble. Maybe I have to think about any synch between the threads.

thanx peter
ScottBot
Site Admin
Posts: 2787
Joined: Thu Feb 13, 2003 6:46 pm
Location: Georgia (USA)
Contact:

Post by ScottBot »

Peter,

The DeviceRun method is only 'complete' when the program exits. That method is called from HB and runs in it's own thread throughout the duration of the program. If you exit it before the application has terminated, that could be a problem.

It's very common for Devices to change property values while in the DeviceRun method. Not just their own properties, but also properties from other Devices.

I don't see how extra threads would create an issue.

How are you issuing the change requests?
Scott
peter
Member
Posts: 35
Joined: Wed May 31, 2006 3:51 am
Location: Berlin , GER

Post by peter »

Scott,
my question was not 100% correct.
I create a separate thread when the DLL is loaded. This thread waits for an event with no timeout. The event is set when the DeviceRun awakes from WaitForMultipleObjects and a particular property has a change request. In my separate thread I call the ChangeRequest method of CPropertyValue to make a change request of another property of the same device.
I think this change request is put to a queue inside of the server part waiting for being processed also in the DeviceRun method.
This could happen before the original DeviceRun loop is finished because of the separate thread.
I don't know how the processing is inside the server when a new request comes in from the separate thread and the DeiviceRun method runs concurrently and updates any property.

hope my question is more precise now.
Post Reply