Hazard pointer is a method of protecting a pointer shared by many threads. If you want to use atomic pointer that may be freed you should
use following code:
string *shared_pointer = ...; HazardPointer<string> hptr = HazardPointer.get_hazard_pointer (&shared_pointer); // my_string contains value from shared_pinter. It is valid as long as hptr is alive. unownedstring my_string = ptr.get (); // instead of delete ptr.release ((ptr) => {string *sptr = ptr;stringref = (owned)sptr;}); });
In some cases you may use helper methods which might involve copying of object (and are unsafe for unowned objects):
Context - Create a new context. User does not
need to create explicitly however it might be benefitial if he is about to issue bunch of commands he might consider it benefitial to
fine-tune the creation of contexts.
Enums:
Policy - Policy determines what happens on exit
from Context.
ReleasePolicy - Release policy
determines what happens with object freed by Policy.TRY_RELEASE and Policy.RELEASE.