Commit 92c564f0 authored by Martin Wierich's avatar Martin Wierich
Browse files

moving IOSt and PSt instances from StdTCPChannels to StdEventTCP

parent 7d3a3323
......@@ -7,7 +7,7 @@ module downloadHTTP
// The program has been written in Clean 1.3.2 and uses the Clean Standard Object I/O library 1.2
//
// **************************************************************************************************
import StdIO
import StdEnv, StdTCP, StdMaybe
from StdSystem import ticksPerSecond
......
......@@ -9,10 +9,8 @@ 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, (PSt .l), (IOSt .l)
instance ChannelEnv World
///////////////////////////////// receive channels /////////////////////////////////
......
......@@ -16,52 +16,6 @@ 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
......
......@@ -12,6 +12,9 @@ from StdReceiver import Receivers, ReceiverType
from StdPSt import PSt, IOSt
from StdIOCommon import ErrorReport
from tcp_bytestreams import TCP_SCharStream_
from StdPStClass import FileEnv, Files, TimeEnv, Date, Tick, Time
instance ChannelEnv (PSt .l), (IOSt .l)
instance Receivers TCP_ListenerReceiver
instance Receivers TCP_Receiver
......
......@@ -10,6 +10,52 @@ import tcp, ostcp, tcp_bytestreams
import commondef, receiverid, receiverdevice, receiverdefaccess, receiveraccess
//import intrface
/* 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
openSendNotifier :: .ls !(SendNotifier *(*ch .a) .ls (PSt .l))
!(PSt .l)
-> (!ErrorReport,!*(*ch .a),!PSt .l)
......
......@@ -4,6 +4,7 @@ import StdEnv, StdMaybe
import StdTCPDef
import StdChannels
import tcp, channelenv, ostick
import code from "cTCP.obj", library "wsock_library"
os_eom :: !EndpointRef !*env
-> (!Bool, !*env)
......
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