@@ -73,11 +73,64 @@ pub fn select2i<A: Selectable, B: Selectable>(a: &A, b: &B) ->
73
73
74
74
// Streams - Make pipes a little easier in general.
75
75
76
- proto! streamp (
76
+ /* proto! streamp (
77
77
Open:send<T: Owned> {
78
78
data(T) -> Open<T>
79
79
}
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
+ }
81
134
82
135
#[doc(hidden)]
83
136
struct Chan_<T> {
@@ -364,11 +417,82 @@ impl<T: Owned, U: Owned,
364
417
}
365
418
}
366
419
367
- proto! oneshot (
420
+ /* proto! oneshot (
368
421
Oneshot:send<T:Owned> {
369
422
send(T) -> !
370
423
}
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
+ }
372
496
373
497
/// The send end of a oneshot pipe.
374
498
pub type ChanOne<T> = oneshot::client::Oneshot<T>;
0 commit comments