Dictionary close

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

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.

Thanks!

--Dave

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

Re: Dictionary close

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

Agreed. I will look into implementing this properly.

-Patrick


Return to “macOS”

Who is online

Users browsing this forum: No registered users and 1 guest