Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

[fix] stdlib/channels: always allow comparison of channels

  • Loading branch information...
commit 2ec1b623e0b0948f35fd14df02a83b0619341bd7 1 parent 666b425
François-Régis Sinot authored
View
20 opabsl/jsbsl/bslSession.js
@@ -363,10 +363,8 @@ var LowLevelPingLoop = {};
compare: function(to) {
if (to instanceof LocalChannel)
return compare_native(this.lchan_id, to.lchan_id);
- else if (to instanceof ServerChannel)
- return 1;
else
- return null;
+ return 1;
},
owner: function(){
@@ -524,9 +522,13 @@ var LowLevelPingLoop = {};
compare: function(to) {
- if(to instanceof CousinClientChannel &&
- this.cl_id == to.cl_id) return 0;
- return null;//Cousin client channels cannot be ordered
+ if(to instanceof CousinClientChannel)
+ return compare_native(this.cl_id == to.cl_id);
+ else
+ if(to instanceof LocalChannel)
+ return -1;
+ else // ServerChannel
+ return 1;
},
owner: function(){
@@ -950,12 +952,10 @@ var LowLevelPingLoop = {};
return false
}
-##register compare_channels_maybe : Session.private.native('msg, 'ctx), Session.private.native('msg, 'ctx) -> option(int)
+##register compare_channels : Session.private.native('msg, 'ctx), Session.private.native('msg, 'ctx) -> int
##args(ch1, ch2)
{
- var result = ch1.compare(ch2);
- if(result==null) return js_none;
- else return js_some(result);
+ return ch1.compare(ch2);
}
##register llsend : Session.private.native('b, 'c), ('b -> RPC.Json.private.native), 'b, option('c) -> void
View
4 opabsl/mlbsl/bslSession.ml
@@ -1192,8 +1192,8 @@ let on_remove_cps chan f k =
##register equals_channel : Session.private.native('msg, 'ctx), Session.private.native('msg, 'ctx) -> bool
let equals_channel a b = Channel.compare a b = 0
-##register compare_channels_maybe : Session.private.native('msg, 'ctx), Session.private.native('msg, 'ctx) -> option(int)
-let compare_channels_maybe a b = Some (Channel.compare a b) (*Server-side comparison of channels always works*)
+##register compare_channels : Session.private.native('msg, 'ctx), Session.private.native('msg, 'ctx) -> int
+let compare_channels a b = Channel.compare a b (*Server-side comparison of channels always works*)
##register get_more : Session.private.native('msg, 'ctx) -> option('more)
let get_more chan =
View
12 stdlib/core/rpc/core/session.opa
@@ -157,14 +157,10 @@ type Session.entity = external
/**
* A partial order on channels
*/
-compare_channel(a:channel('msg), b:channel('msg)): Order.comparison =
- compare_raw = %%BslSession.compare_channels_maybe%%
- match compare_raw(a, b) with
- | {none} -> {neq}
- | ~{some}-> Order.of_int(some) <: Order.comparison
-
-//TODO: Unsafe! We may need to find another mechanism for Network!
-channel_order = @nonexpansive(Order.make_unsafe(compare_channel)) : order(channel('message),Channel.order)
+compare_channel(a:channel('msg), b:channel('msg)) : Order.ordering =
+ Order.of_int(%%BslSession.compare_channels%%(a, b))
+
+channel_order = @nonexpansive(Order.make(compare_channel)) : order(channel('message),Channel.order)
/** The Hlnet definitions for the protocol for "make_at" queries */
type make_at_query = (OpaType.ty, OpaType.ty, RPC.Json.json, RPC.Json.json)
Please sign in to comment.
Something went wrong with that request. Please try again.