3 LKDictionary(new
:NewLKDic
)
17 class LayerManagerClass
21 layers
:=nonInitialized
24 layers
:={Dictionary
.new
}
25 {self introduceLayer(AlarmLayer
)}
26 for F
in [remoteProcess router localProcess
] do
27 {self introduceLayer(Comm
.F
)}
29 for F
in [comm process bep2p pp2p ifd pfd
] do
30 {self introduceLayer(Dist
.F
)}
33 meth introduceLayer(LayerFunc
)
35 LayerClass
={LayerFunc
self LayerUri
}
37 fun{{self getLayer(LayerUri $
)} UserInit
}
38 {New LayerClass
SessionInit(UserInit $
) _
}
42 {Dictionary
.condExchange
@layers Uri _ N N
}
45 LayerManager
={New LayerManagerClass
PreInit()}
48 meth !SessionInit(UserInit ?This
)
50 proc{This M
} {@this M
} end
51 this
:=proc{$ M
} {Send P M
} end
62 if {HasFeature S L
} then
63 {@this
{Adjoin M S
.L
}}
69 fun{AlarmLayer LM ?Uri
}
77 Now
={Property
.get 'time
.total'
}
78 NAl
={List
.takeDropWhile OAl
fun{$ T
#_
#_
}T
<Now
end ToDo $
}
80 {{Sessions
get(S $
)} alarm(P
)}
83 {Delay
{Max
0 Now
-NAl
.1.1}}
88 Uri
='dist
-layer
:alarm'
91 meth init(SId Handler
)
93 {Sessions
put(@sid Handler
)}
96 {Property
.get 'time
.total'
}
98 meth setAlarmAt(Time Payload
)
101 NAl
={List
.merge OAl
[Time
#@sid
#Payload
] fun{$ X
#_
#_ Y
#_
#_
}X
<Y
end}
102 if OAl
==nil
orelse OAl
.1.1 > Time
then
104 {Delay
{Max
0 Time
-{self getTime($
)}}}
109 meth setAlarmIn(Interval Payload
)
110 {self setAlarmAt({self getTime($
)}+Interval Payload
)}