Comment 55 for bug 587597

Revision history for this message
Crise / MW (markuwil) wrote : Re: Plugins support

Regarding thread safety, being something arne brought up... the result is to sum it up in one word: ugly. The two major functional interfaces (DCHub and DCQueue) now have release(...) and copy(...) functions in them, the respective *Data structs also have an isManaged member that is False if release must be called for said object.

Where copies are not made by dcpp thread safety is achieved by string cache and use of locks. Which means if plugins need to take the passed managed object outside calls which are direct descendants of the call to PluginManager::runHook they are responsible of making a copy of the object using the copy function and also taking care not to use resulting objects after their "handle" (ie. object member of f.ex. HubData) is out of scope, which they can track with certain events (such as onHubOnline/onHubOffline).

Of course the object handle of UserData has been eliminated as unsafe... we could also eliminate the equivalent handle in HubData, but i see no reason for that because we can track the situation where that handle (or any copies plugins created) becomes invalid on plugin side.