Commit d78c66d9 authored by Peter Achten's avatar Peter Achten
Browse files

no message

parent 4c7e928d
definition module StdChannelEnv
// ********************************************************************************
// Clean Standard Object I/O library, version 1.2
//
// StdChannelEnv defines instances of ChannelEnv for PSt and IOSt.
// ********************************************************************************
import channelenv
import StdPStClass
from iostate import PSt, IOSt
instance ChannelEnv (PSt .l)
instance ChannelEnv (IOSt .l)
implementation module StdChannelEnv
import StdBool, StdFunc, StdList, StdMisc, StdTuple
import channelenv
import commondef, iostate, receiverid, StdPStClass, StdReceiver
/* PSt is also an environment instance of the class ChannelEnv */
instance ChannelEnv (PSt .l)
where
channelEnvKind env
= (PST, env)
mb_close_inet_receiver_without_id reallyDoIt id_pair pSt=:{io}
= { pSt & io = mb_close_inet_receiver_without_id True id_pair io }
/* IOSt is also an environment instance of the class ChannelEnv */
instance ChannelEnv (IOSt .l)
where
channelEnvKind env
= (IOST, env)
mb_close_inet_receiver_without_id False _ ioState
= ioState
mb_close_inet_receiver_without_id True id_pair ioState
#! (closed,ioState) = IOStClosed ioState
| closed
= ioState
# (found,receivers,ioState) = IOStGetDevice ReceiverDevice ioState
| not found // PA: guard added
= ioState
# rsHs = (ReceiverSystemStateGetReceiverHandles receivers).rReceivers
(found,rsH,rsHs) = Remove (inetReceiverStateIdentified1 id_pair) undef rsHs
# ioState = IOStSetDevice (ReceiverSystemState {rReceivers=rsHs}) ioState
| not found
= ioState
| otherwise
# id = rsH.rHandle.rId
(idtable,ioState) = IOStGetIdTable ioState
ioState = IOStSetIdTable (snd (removeIdFromIdTable id idtable)) ioState
ioState = unbindRId id ioState
ioState = IOStSetRcvDisabled True ioState // MW11++
connectedIds = rsH.rHandle.rConnected
ioState = seq (map closeReceiver connectedIds) ioState
inetInfo = rsH.rHandle.rInetInfo
(_,_,_,closeFun) = fromJust inetInfo
ioState = appIOToolbox closeFun ioState
= ioState
inetReceiverStateIdentified1 :: !(!EndpointRef`, !InetReceiverCategory`) !(ReceiverStateHandle .ps) -> Bool
inetReceiverStateIdentified1 x {rHandle} = inetReceiverIdentified x rHandle
......@@ -9,9 +9,10 @@ definition module StdChannels
from StdMaybe import Maybe
from StdOverloaded import ==, toString
from channelenv import ChannelEnv
from iostate import PSt, IOSt
import StdPStClass
instance ChannelEnv World
// other instances are IOSt & PSt (see StdChannelEnv)
instance ChannelEnv World, (PSt .l), (IOSt .l)
///////////////////////////////// receive channels /////////////////////////////////
......
......@@ -8,6 +8,7 @@ import StdMaybe
import StdIOCommon, StdTime
import channelenv
import id
import commondef, iostate, receiverid, StdPStClass, StdReceiver
instance ChannelEnv World
where
......@@ -15,6 +16,52 @@ instance ChannelEnv World
mb_close_inet_receiver_without_id _ _ world
= world
/* PSt is also an environment instance of the class ChannelEnv */
instance ChannelEnv (PSt .l)
where
channelEnvKind env
= (PST, env)
mb_close_inet_receiver_without_id reallyDoIt id_pair pSt=:{io}
= { pSt & io = mb_close_inet_receiver_without_id True id_pair io }
/* IOSt is also an environment instance of the class ChannelEnv */
instance ChannelEnv (IOSt .l)
where
channelEnvKind env
= (IOST, env)
mb_close_inet_receiver_without_id False _ ioState
= ioState
mb_close_inet_receiver_without_id True id_pair ioState
#! (closed,ioState) = IOStClosed ioState
| closed
= ioState
# (found,receivers,ioState) = IOStGetDevice ReceiverDevice ioState
| not found // PA: guard added
= ioState
# rsHs = (ReceiverSystemStateGetReceiverHandles receivers).rReceivers
(found,rsH,rsHs) = Remove (inetReceiverStateIdentified1 id_pair) undef rsHs
# ioState = IOStSetDevice (ReceiverSystemState {rReceivers=rsHs}) ioState
| not found
= ioState
| otherwise
# id = rsH.rHandle.rId
(idtable,ioState) = IOStGetIdTable ioState
ioState = IOStSetIdTable (snd (removeIdFromIdTable id idtable)) ioState
ioState = unbindRId id ioState
ioState = IOStSetRcvDisabled True ioState // MW11++
connectedIds = rsH.rHandle.rConnected
ioState = seq (map closeReceiver connectedIds) ioState
inetInfo = rsH.rHandle.rInetInfo
(_,_,_,closeFun) = fromJust inetInfo
ioState = appIOToolbox closeFun ioState
= ioState
inetReceiverStateIdentified1 :: !(!EndpointRef`, !InetReceiverCategory`) !(ReceiverStateHandle .ps) -> Bool
inetReceiverStateIdentified1 x {rHandle} = inetReceiverIdentified x rHandle
///////////////////////////////// receive channels /////////////////////////////////
class Receive ch
......
......@@ -3,7 +3,7 @@ implementation module StdEventTCP
// Clean Standard Object I/O library, version 1.2
import StdEnv
import StdChannelEnv, StdChannels, StdTCPDef, StdTCPChannels
import /*StdChannelEnv,*/ StdChannels, StdTCPDef, StdTCPChannels
import StdReceiver
import StdPSt, StdPStClass
import tcp, ostcp, tcp_bytestreams
......
definition module StdTCP
import StdChannelEnv,
StdChannels,
import StdChannels,
StdTCPChannels,
StdEventTCP,
StdStringChannels,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment