Dictionary close

Supporting 10.7 and up
Posts: 30
Joined: Mon Feb 07, 2011 1:14 am

Dictionary close

Postby dkatz42 » Mon Mar 07, 2011 6:49 pm

In an earlier item I described issues I was having regarding writing a bunch of KV pairs to the dictionary and getting a "socket closed" error back in mid-stream.

It turns out that this is because my program attempts to open the dictionary, emit a bunch of KV pairs, and close the dictionary. Apparently CPhidgetDictionary_close() is immediate and pays no attention to content that is queued for transmission to the server; the "socket closed" error is presumably because the writer thread is still trying to crank out KV pairs and the dictionary closes beneath it.

It appears to me that there is no mechanism to close the dictionary in an graceful fashion--basically, you have to wait "long enough" before closing it. This seems like a hole in the API.

Most open/close protocols have a "graceful" close and an "immediate" close as an option. Could you add one? Probably the only backward-compatible mechanism would be to add a separate call for the graceful close. You could then use the server disconnect callback to signal when the close completed. Extra credit for having an option for a blocking version of the close call for folks that aren't implementing the full even-driven paradigm.

While I can work around this issue, it does appear to be a fundamental flaw in the dictionary library, and it would be nice for it to be fixed.



User avatar
Lead Developer
Posts: 3165
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada

Re: Dictionary close

Postby Patrick » Tue Mar 08, 2011 2:21 pm

Agreed. I will look into implementing this properly.


Return to “macOS”

Who is online

Users browsing this forum: No registered users and 2 guests