Skip to content

Commit 78fcdd0

Browse files
committed
---
yaml --- r: 139877 b: refs/heads/try2 c: 056164a h: refs/heads/master i: 139875: f51a302 v: v3
1 parent e03782a commit 78fcdd0

File tree

2 files changed

+129
-5
lines changed

2 files changed

+129
-5
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 3dce936753b90dcf80f25251034ccee7afd8ea71
8+
refs/heads/try2: 056164ac1946898cb46ec075f1bd4c15dfbeff30
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/comm.rs

Lines changed: 128 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,64 @@ pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) ->
7373
7474
// Streams - Make pipes a little easier in general.
7575
76-
proto! streamp (
76+
/*proto! streamp (
7777
Open:send<T: Owned> {
7878
data(T) -> Open<T>
7979
}
80-
)
80+
)*/
81+
82+
#[allow(non_camel_case_types)]
83+
pub mod streamp {
84+
priv use core::kinds::Owned;
85+
86+
pub fn init<T: Owned>() -> (client::Open<T>, server::Open<T>) {
87+
pub use core::pipes::HasBuffer;
88+
::core::pipes::entangle()
89+
}
90+
91+
#[allow(non_camel_case_types)]
92+
pub enum Open<T> { pub data(T, server::Open<T>), }
93+
94+
#[allow(non_camel_case_types)]
95+
pub mod client {
96+
priv use core::kinds::Owned;
97+
98+
#[allow(non_camel_case_types)]
99+
pub fn try_data<T: Owned>(pipe: Open<T>, x_0: T) ->
100+
::core::option::Option<Open<T>> {
101+
{
102+
use super::data;
103+
let (c, s) = ::core::pipes::entangle();
104+
let message = data(x_0, s);
105+
if ::core::pipes::send(pipe, message) {
106+
::core::pipes::rt::make_some(c)
107+
} else { ::core::pipes::rt::make_none() }
108+
}
109+
}
110+
111+
#[allow(non_camel_case_types)]
112+
pub fn data<T: Owned>(pipe: Open<T>, x_0: T) -> Open<T> {
113+
{
114+
use super::data;
115+
let (c, s) = ::core::pipes::entangle();
116+
let message = data(x_0, s);
117+
::core::pipes::send(pipe, message);
118+
c
119+
}
120+
}
121+
122+
#[allow(non_camel_case_types)]
123+
pub type Open<T> = ::core::pipes::SendPacket<super::Open<T>>;
124+
}
125+
126+
#[allow(non_camel_case_types)]
127+
pub mod server {
128+
priv use core::kinds::Owned;
129+
130+
#[allow(non_camel_case_types)]
131+
pub type Open<T> = ::core::pipes::RecvPacket<super::Open<T>>;
132+
}
133+
}
81134
82135
#[doc(hidden)]
83136
struct Chan_<T> {
@@ -364,11 +417,82 @@ impl<T: Owned, U: Owned,
364417
}
365418
}
366419
367-
proto! oneshot (
420+
/*proto! oneshot (
368421
Oneshot:send<T:Owned> {
369422
send(T) -> !
370423
}
371-
)
424+
)*/
425+
426+
#[allow(non_camel_case_types)]
427+
pub mod oneshot {
428+
priv use core::kinds::Owned;
429+
430+
pub fn init<T: Owned>() -> (client::Oneshot<T>, server::Oneshot<T>) {
431+
pub use core::pipes::HasBuffer;
432+
433+
let buffer =
434+
~::core::pipes::Buffer{
435+
header: ::core::pipes::BufferHeader(),
436+
data: __Buffer{
437+
Oneshot: ::core::pipes::mk_packet::<Oneshot<T>>()
438+
},
439+
};
440+
do ::core::pipes::entangle_buffer(buffer) |buffer, data| {
441+
{
442+
data.Oneshot.set_buffer(buffer);
443+
::ptr::addr_of(&(data.Oneshot))
444+
}
445+
}
446+
}
447+
#[allow(non_camel_case_types)]
448+
pub enum Oneshot<T> { pub send(T), }
449+
#[allow(non_camel_case_types)]
450+
pub struct __Buffer<T> {
451+
Oneshot: ::core::pipes::Packet<Oneshot<T>>,
452+
}
453+
454+
#[allow(non_camel_case_types)]
455+
pub mod client {
456+
457+
priv use core::kinds::Owned;
458+
459+
#[allow(non_camel_case_types)]
460+
pub fn try_send<T: Owned>(pipe: Oneshot<T>, x_0: T) ->
461+
::core::option::Option<()> {
462+
{
463+
use super::send;
464+
let message = send(x_0);
465+
if ::core::pipes::send(pipe, message) {
466+
::core::pipes::rt::make_some(())
467+
} else { ::core::pipes::rt::make_none() }
468+
}
469+
}
470+
471+
#[allow(non_camel_case_types)]
472+
pub fn send<T: Owned>(pipe: Oneshot<T>, x_0: T) {
473+
{
474+
use super::send;
475+
let message = send(x_0);
476+
::core::pipes::send(pipe, message);
477+
}
478+
}
479+
480+
#[allow(non_camel_case_types)]
481+
pub type Oneshot<T> =
482+
::core::pipes::SendPacketBuffered<super::Oneshot<T>,
483+
super::__Buffer<T>>;
484+
}
485+
486+
#[allow(non_camel_case_types)]
487+
pub mod server {
488+
priv use core::kinds::Owned;
489+
490+
#[allow(non_camel_case_types)]
491+
pub type Oneshot<T> =
492+
::core::pipes::RecvPacketBuffered<super::Oneshot<T>,
493+
super::__Buffer<T>>;
494+
}
495+
}
372496
373497
/// The send end of a oneshot pipe.
374498
pub type ChanOne<T> = oneshot::client::Oneshot<T>;

0 commit comments

Comments
 (0)