Make your own free website on Tripod.com

File : oci-thread.ads


with 
  Ada.Task_Attributes,
  OCI.Lib,
  OCI.Task_Error,
  Ada.Task_Identification,
  OCI.Task_Environment;
use 
   OCI.Task_Error,
   OCI.Task_Environment,
   Ada.Task_Identification,
   OCI.Lib;
package OCI.Thread is 

  function Error return OCIError;
  function Environment return OCIEnv;
  
   protected Synch is
      procedure Same_Environment_In(
         Task_ID1 : Task_ID;
         Task_ID2 : Task_ID := Current_Task);
      function Environment return Thread_Environment;
   end Synch;

  -- Setup the same environment in 2 different tasks
  -- otherwise every task will have different environments.
  -- if both tasks have Environments created 
  -- (it happens after first call to any OCI related function automaticaly)
  -- an exception will be raise;
  procedure Same_Environment_In(
         Task_ID1 : Task_ID;
         Task_ID2 : Task_ID := Current_Task) renames Synch.Same_Environment_In;

     THE_SAME_TASKS : exception;
     BOTH_ENVIRONMENT_ALREADY_CREATED : exception;

private

  package Environment_attr is new
      Ada.Task_Attributes(Thread_Environment, Init_Environment);

  package Error_attr is new
      Ada.Task_Attributes(Thread_Error, Init_Error);
      
end OCI.Thread