BaseThread.F90 Source File


This file depends on

sourcefile~~basethread.f90~~EfferentGraph sourcefile~basethread.f90 BaseThread.F90 sourcefile~abstractrequesthandle.f90 AbstractRequestHandle.F90 sourcefile~basethread.f90->sourcefile~abstractrequesthandle.f90 sourcefile~abstractsocket.f90 AbstractSocket.F90 sourcefile~basethread.f90->sourcefile~abstractsocket.f90 sourcefile~integerrequestmap.f90 IntegerRequestMap.F90 sourcefile~basethread.f90->sourcefile~integerrequestmap.f90 sourcefile~mapl_exceptionhandling.f90 MAPL_ExceptionHandling.F90 sourcefile~basethread.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~messagevisitor.f90 MessageVisitor.F90 sourcefile~basethread.f90->sourcefile~messagevisitor.f90 sourcefile~pfio_base.f90 pfio_base.F90 sourcefile~basethread.f90->sourcefile~pfio_base.f90 sourcefile~abstractdatareference.f90 AbstractDataReference.F90 sourcefile~abstractrequesthandle.f90->sourcefile~abstractdatareference.f90 sourcefile~integerrequestmap.f90->sourcefile~abstractrequesthandle.f90 sourcefile~mapl_errorhandling.f90 MAPL_ErrorHandling.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_errorhandling.f90 sourcefile~mapl_throw.f90 MAPL_Throw.F90 sourcefile~mapl_exceptionhandling.f90->sourcefile~mapl_throw.f90 sourcefile~messagevisitor.f90->sourcefile~abstractrequesthandle.f90 sourcefile~messagevisitor.f90->sourcefile~mapl_exceptionhandling.f90 sourcefile~abstractmessage.f90 AbstractMessage.F90 sourcefile~messagevisitor.f90->sourcefile~abstractmessage.f90 sourcefile~addextcollectionmessage.f90 AddExtCollectionMessage.F90 sourcefile~messagevisitor.f90->sourcefile~addextcollectionmessage.f90 sourcefile~addhistcollectionmessage.f90 AddHistCollectionMessage.F90 sourcefile~messagevisitor.f90->sourcefile~addhistcollectionmessage.f90 sourcefile~collectiveprefetchdatamessage.f90 CollectivePrefetchDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectiveprefetchdatamessage.f90 sourcefile~collectiveprefetchdonemessage.f90 CollectivePrefetchDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectiveprefetchdonemessage.f90 sourcefile~collectivestagedatamessage.f90 CollectiveStageDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectivestagedatamessage.f90 sourcefile~collectivestagedonemessage.f90 CollectiveStageDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~collectivestagedonemessage.f90 sourcefile~donemessage.f90 DoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~donemessage.f90 sourcefile~dummymessage.f90 DummyMessage.F90 sourcefile~messagevisitor.f90->sourcefile~dummymessage.f90 sourcefile~handshakemessage.f90 HandShakeMessage.F90 sourcefile~messagevisitor.f90->sourcefile~handshakemessage.f90 sourcefile~idmessage.f90 IDMessage.F90 sourcefile~messagevisitor.f90->sourcefile~idmessage.f90 sourcefile~modifymetadatamessage.f90 ModifyMetadataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~modifymetadatamessage.f90 sourcefile~prefetchdatamessage.f90 PrefetchDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~prefetchdatamessage.f90 sourcefile~prefetchdonemessage.f90 PrefetchDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~prefetchdonemessage.f90 sourcefile~replacemetadatamessage.f90 ReplaceMetadataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~replacemetadatamessage.f90 sourcefile~stagedatamessage.f90 StageDataMessage.F90 sourcefile~messagevisitor.f90->sourcefile~stagedatamessage.f90 sourcefile~stagedonemessage.f90 StageDoneMessage.F90 sourcefile~messagevisitor.f90->sourcefile~stagedonemessage.f90 sourcefile~terminatemessage.f90 TerminateMessage.F90 sourcefile~messagevisitor.f90->sourcefile~terminatemessage.f90 sourcefile~pfio_base.f90->sourcefile~mapl_errorhandling.f90

Files dependent on this one

sourcefile~~basethread.f90~~AfferentGraph sourcefile~basethread.f90 BaseThread.F90 sourcefile~clientthread.f90 ClientThread.F90 sourcefile~clientthread.f90->sourcefile~basethread.f90 sourcefile~simplesocket.f90 SimpleSocket.F90 sourcefile~clientthread.f90->sourcefile~simplesocket.f90 sourcefile~mockclientthread.f90 MockClientThread.F90 sourcefile~mockclientthread.f90->sourcefile~basethread.f90 sourcefile~mockclientthread.f90->sourcefile~clientthread.f90 sourcefile~mockclientthread.f90->sourcefile~simplesocket.f90 sourcefile~serverthread.f90 ServerThread.F90 sourcefile~serverthread.f90->sourcefile~basethread.f90 sourcefile~serverthread.f90->sourcefile~simplesocket.f90 sourcefile~simplesocket.f90->sourcefile~basethread.f90 sourcefile~test_simplesocket.pf Test_SimpleSocket.pf sourcefile~test_simplesocket.pf->sourcefile~basethread.f90 sourcefile~test_simplesocket.pf->sourcefile~clientthread.f90 sourcefile~test_simplesocket.pf->sourcefile~serverthread.f90 sourcefile~test_simplesocket.pf->sourcefile~simplesocket.f90 sourcefile~baseserver.f90 BaseServer.F90 sourcefile~baseserver.f90->sourcefile~serverthread.f90 sourcefile~baseserver.f90->sourcefile~simplesocket.f90 sourcefile~clientmanager.f90 ClientManager.F90 sourcefile~clientmanager.f90->sourcefile~clientthread.f90 sourcefile~clientthreadvector.f90 ClientThreadVector.F90 sourcefile~clientthreadvector.f90->sourcefile~clientthread.f90 sourcefile~directoryservice.f90 DirectoryService.F90 sourcefile~directoryservice.f90->sourcefile~clientthread.f90 sourcefile~directoryservice.f90->sourcefile~serverthread.f90 sourcefile~directoryservice.f90->sourcefile~simplesocket.f90 sourcefile~fastclientthread.f90 FastClientThread.F90 sourcefile~fastclientthread.f90->sourcefile~clientthread.f90 sourcefile~mockclient.f90 MockClient.F90 sourcefile~mockclient.f90->sourcefile~clientthread.f90 sourcefile~mockserverthread.f90 MockServerThread.F90 sourcefile~mockserverthread.f90->sourcefile~serverthread.f90 sourcefile~mpiserver.f90 MpiServer.F90 sourcefile~mpiserver.f90->sourcefile~serverthread.f90 sourcefile~multicommserver.f90 MultiCommServer.F90 sourcefile~multicommserver.f90->sourcefile~serverthread.f90 sourcefile~multigroupserver.f90 MultiGroupServer.F90 sourcefile~multigroupserver.f90->sourcefile~serverthread.f90 sourcefile~multilayerserver.f90 MultiLayerServer.F90 sourcefile~multilayerserver.f90->sourcefile~serverthread.f90 sourcefile~openmpserver.f90 OpenMPServer.F90 sourcefile~openmpserver.f90->sourcefile~serverthread.f90 sourcefile~pfio.f90 pFIO.F90 sourcefile~pfio.f90->sourcefile~clientthread.f90 sourcefile~pfio.f90->sourcefile~serverthread.f90 sourcefile~pfio.f90->sourcefile~simplesocket.f90 sourcefile~serverthreadvector.f90 ServerThreadVector.F90 sourcefile~serverthreadvector.f90->sourcefile~serverthread.f90 sourcefile~test_client.pf Test_Client.pf sourcefile~test_client.pf->sourcefile~mockclientthread.f90 sourcefile~test_serverthread.pf Test_ServerThread.pf sourcefile~test_serverthread.pf->sourcefile~serverthread.f90

Source Code

#include "MAPL_ErrLog.h"
#include "unused_dummy.H"

module pFIO_BaseThreadMod
   use MAPL_ExceptionHandling
   use pFIO_AbstractSocketMod
   use pFIO_AbstractRequestHandleMod
   use pFIO_IntegerRequestMapMod
   use pFIO_MessageVisitorMod
   use pfio_base
   use mpi

   implicit none
   private

   public :: BaseThread

   
   type, extends(MessageVisitor),abstract :: BaseThread
      private
      class (AbstractSocket), allocatable :: connection
      type (IntegerRequestMap) :: open_requests
   contains
   
      procedure :: get_connection
      procedure :: set_connection

      procedure :: erase_RequestHandle
      procedure :: clear_RequestHandle
      procedure :: get_RequestHandle
      procedure :: insert_RequestHandle
      procedure :: isEmpty_RequestHandle
   end type BaseThread

contains

   function get_connection(this, rc) result(connection)
      class (BaseThread), target, intent(in) :: this
      class (AbstractSocket), pointer :: connection
      integer, optional, intent(out) :: rc
      _ASSERT(allocated(this%connection), "no connection")
      connection => this%connection
      _RETURN(_SUCCESS)
   end function get_connection

   subroutine set_connection(this, connection, rc)
      class(BaseThread),target,intent(inout) :: this
      class (AbstractSocket), intent(in) :: connection
      integer, optional, intent(out) :: rc

      if(allocated(this%connection)) deallocate(this%connection)
      allocate(this%connection, source=connection)

      _RETURN(_SUCCESS)
   end subroutine set_connection
   
   function get_RequestHandle(this,request_id, rc) result(rh_ptr)
      class (BaseThread), target, intent(in) :: this
      integer, intent(in) :: request_id
      integer, optional, intent(out) :: rc
      class(AbstractRequestHandle), pointer :: rh_ptr
      type (IntegerRequestMapIterator) :: iter

      iter = this%open_requests%find(request_id)
      _ASSERT( iter /= this%open_requests%end(), "could not find the request handle id")
      rh_Ptr => iter%value()
      _RETURN(_SUCCESS)
   end function get_RequestHandle

   function isEmpty_RequestHandle(this, rc) result(empty)
      class (BaseThread), target, intent(in) :: this
      integer, optional, intent(out) :: rc
      logical :: empty
      type (IntegerRequestMapIterator) :: iter

      iter  = this%open_requests%begin()
      empty = (iter == this%open_requests%end())
      _RETURN(_SUCCESS)
   end function isEmpty_RequestHandle

   subroutine insert_RequestHandle(this,request_id, handle, rc) 
      class (BaseThread), target, intent(inout) :: this
      integer, intent(in) :: request_id
      class(AbstractRequestHandle), intent(in):: handle
      integer, optional, intent(out) :: rc

      call this%open_requests%insert(request_id, handle)

      _RETURN(_SUCCESS)
   end subroutine insert_RequestHandle

   subroutine erase_RequestHandle(this,request_id, rc)
      class(BaseThread), target, intent(inout) :: this
      integer, intent(in) :: request_id
      integer, optional, intent(out) :: rc
      type(IntegerRequestMapIterator) :: iter

      iter = this%open_requests%find(request_id)
      call  this%open_requests%erase(iter)

      _RETURN(_SUCCESS)
   end subroutine erase_RequestHandle

   subroutine clear_RequestHandle(this, rc)
      class(BaseThread), target, intent(inout) :: this
      integer, optional, intent(out) :: rc

      class(AbstractRequestHandle), pointer :: rh_ptr
      type (IntegerRequestMapIterator) :: iter
      integer :: status

      iter = this%open_requests%begin()
      do while (iter /= this%open_requests%end())
        rh_ptr => iter%value()
        call rh_ptr%wait()
        call rh_ptr%data_reference%deallocate(status)
        _VERIFY(status)

        call this%open_requests%erase(iter)
        iter = this%open_requests%begin()
      enddo

      _RETURN(_SUCCESS)
   end subroutine clear_RequestHandle

end module pFIO_BaseThreadMod