This is the mail archive of the gcc-patches@gcc.gnu.org mailing list for the GCC project.
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |
Other format: | [Raw text] |
This change implements a new feature in the tasking runtime library: if Unchecked_Deallocation is called on a non-terminated task (which was previously a no-op), the task is now marked to be freed automatically when it terminates. The following test case demonstrates the feature: $ gnatmake -q -z free_nonterm_task When executing free_nonterm_task under valgrind, no memory leak corresponding to the creation of task T (in System.Tasking.Stages.Create_Task) shall be reported. package Free_Nonterm_Task is pragma Elaborate_Body; end Free_Nonterm_Task; with Ada.Unchecked_Deallocation; with Ada.Text_IO; use Ada.Text_IO; package body Free_Nonterm_Task is type T; type A is access T; task type T is entry Term (Self : in out A); end T; procedure Free is new Ada.Unchecked_Deallocation (T, A); task body T is begin Put_Line ("T: enter"); accept Term (Self : in out A) do Free (Self); end Term; Put_Line ("T: exit"); end T; My_Task : A; begin Put_Line ("Create task"); My_Task := new T; Put_Line ("Call Term"); My_Task.Term (My_Task); end Free_Nonterm_Task; Tested on x86_64-pc-linux-gnu, committed on trunk 2011-09-06 Thomas Quinot <quinot@adacore.com> * s-tassta.adb, s-taskin.ads (Free_Task): If the task is not terminated, mark it for deallocation upon termination. (Terminate_Task): Call Free_Task again if the task is marked for automatic deallocation upon termination.
Attachment:
difs
Description: Text document
Index Nav: | [Date Index] [Subject Index] [Author Index] [Thread Index] | |
---|---|---|
Message Nav: | [Date Prev] [Date Next] | [Thread Prev] [Thread Next] |