Patent ID: 8234645

Claim:
An apparatus, comprising: a memory within which is resident a data structure; at least one processor configured to execute a plurality of threads; and first program code configured to be executed by the at least one processor to deallocate the data structure by, in response to a request to deallocate the data structure, setting a shared pointer to the data structure to a predetermined value that indicates to a thread thereafter attempting to use the pointer that the data structure is not available, waiting until each of the plurality of threads is no longer using the shared pointer by monitoring said each thread to determine whether said each thread is executing second program code that is capable of using the shared pointer to access the data structure, and deallocating the data structure after setting the shared pointer to the predetermined value and waiting until said each of the plurality of threads is no longer using the shared pointer; wherein the first program code is configured to determine whether said each thread is executing the second program code by determining that said each thread among the plurality of threads is no longer using the shared pointer in response to meeting at least one of a plurality of conditions that includes a first condition where said each thread is inactive, a second condition where said each thread is executing in an idle loop, a third condition where said each thread is currently executing program code other than the second program code, and a fourth condition where said each thread has exited the second program code, wherein the first program code includes at least a first instruction configured to test the first condition, at least a second instruction configured to test the second condition, at least a third instruction configured to test the third condition and at least a fourth instruction configured to test the fourth condition, wherein the first program code is configured to determine whether said each thread is executing the second program code by determining whether an indicator associated with said each thread indicates that said each thread is currently executing the second program code or that said each thread has exited the second program code, wherein the indicator is updated from a first value to a second value whenever said each thread enters the second program code, and is updated from the second value to a third value whenever said each thread exits the second program code, and wherein the first program code is configured to determine whether the indicator associated with said each thread indicates that said each thread has exited the second program code by comparing the indicator with an earlier value thereof.