rustuv: Switch field privacy as necessary
This commit is contained in:
parent
fab0f47fdf
commit
f0ee509229
11 changed files with 74 additions and 74 deletions
|
@ -22,12 +22,12 @@ use std::rt::local::Local;
|
|||
use homing::HomingMissile;
|
||||
|
||||
pub struct Access {
|
||||
priv inner: UnsafeArc<Inner>,
|
||||
inner: UnsafeArc<Inner>,
|
||||
}
|
||||
|
||||
pub struct Guard<'a> {
|
||||
priv access: &'a mut Access,
|
||||
priv missile: Option<HomingMissile>,
|
||||
access: &'a mut Access,
|
||||
missile: Option<HomingMissile>,
|
||||
}
|
||||
|
||||
struct Inner {
|
||||
|
|
|
@ -26,14 +26,14 @@ use uvll;
|
|||
|
||||
pub struct FsRequest {
|
||||
req: *uvll::uv_fs_t,
|
||||
priv fired: bool,
|
||||
fired: bool,
|
||||
}
|
||||
|
||||
pub struct FileWatcher {
|
||||
priv loop_: Loop,
|
||||
priv fd: c_int,
|
||||
priv close: rtio::CloseBehavior,
|
||||
priv home: HomeHandle,
|
||||
loop_: Loop,
|
||||
fd: c_int,
|
||||
close: rtio::CloseBehavior,
|
||||
home: HomeHandle,
|
||||
}
|
||||
|
||||
impl FsRequest {
|
||||
|
|
|
@ -48,8 +48,8 @@ use queue::{Queue, QueuePool};
|
|||
/// Handles are clone-able in order to derive new handles from existing handles
|
||||
/// (very useful for when accepting a socket from a server).
|
||||
pub struct HomeHandle {
|
||||
priv queue: Queue,
|
||||
priv id: uint,
|
||||
queue: Queue,
|
||||
id: uint,
|
||||
}
|
||||
|
||||
impl HomeHandle {
|
||||
|
@ -126,7 +126,7 @@ pub trait HomingIO {
|
|||
/// task back to its appropriate home (if applicable). The field is used to
|
||||
/// assert that we are where we think we are.
|
||||
pub struct HomingMissile {
|
||||
priv io_home: uint,
|
||||
io_home: uint,
|
||||
}
|
||||
|
||||
impl HomingMissile {
|
||||
|
|
|
@ -197,8 +197,8 @@ pub trait UvHandle<T> {
|
|||
}
|
||||
|
||||
pub struct ForbidSwitch {
|
||||
priv msg: &'static str,
|
||||
priv io: uint,
|
||||
msg: &'static str,
|
||||
io: uint,
|
||||
}
|
||||
|
||||
impl ForbidSwitch {
|
||||
|
@ -261,8 +261,8 @@ fn wakeup(slot: &mut Option<BlockedTask>) {
|
|||
}
|
||||
|
||||
pub struct Request {
|
||||
handle: *uvll::uv_req_t,
|
||||
priv defused: bool,
|
||||
pub handle: *uvll::uv_req_t,
|
||||
defused: bool,
|
||||
}
|
||||
|
||||
impl Request {
|
||||
|
@ -313,7 +313,7 @@ impl Drop for Request {
|
|||
/// with dtors may not be destructured, but tuple structs can,
|
||||
/// but the results are not correct.
|
||||
pub struct Loop {
|
||||
priv handle: *uvll::uv_loop_t
|
||||
handle: *uvll::uv_loop_t
|
||||
}
|
||||
|
||||
impl Loop {
|
||||
|
|
|
@ -153,22 +153,22 @@ pub struct TcpWatcher {
|
|||
handle: *uvll::uv_tcp_t,
|
||||
stream: StreamWatcher,
|
||||
home: HomeHandle,
|
||||
priv refcount: Refcount,
|
||||
refcount: Refcount,
|
||||
|
||||
// libuv can't support concurrent reads and concurrent writes of the same
|
||||
// stream object, so we use these access guards in order to arbitrate among
|
||||
// multiple concurrent reads and writes. Note that libuv *can* read and
|
||||
// write simultaneously, it just can't read and read simultaneously.
|
||||
priv read_access: Access,
|
||||
priv write_access: Access,
|
||||
read_access: Access,
|
||||
write_access: Access,
|
||||
}
|
||||
|
||||
pub struct TcpListener {
|
||||
home: HomeHandle,
|
||||
handle: *uvll::uv_pipe_t,
|
||||
priv closing_task: Option<BlockedTask>,
|
||||
priv outgoing: Sender<Result<~rtio::RtioTcpStream:Send, IoError>>,
|
||||
priv incoming: Receiver<Result<~rtio::RtioTcpStream:Send, IoError>>,
|
||||
closing_task: Option<BlockedTask>,
|
||||
outgoing: Sender<Result<~rtio::RtioTcpStream:Send, IoError>>,
|
||||
incoming: Receiver<Result<~rtio::RtioTcpStream:Send, IoError>>,
|
||||
}
|
||||
|
||||
pub struct TcpAcceptor {
|
||||
|
@ -476,9 +476,9 @@ pub struct UdpWatcher {
|
|||
home: HomeHandle,
|
||||
|
||||
// See above for what these fields are
|
||||
priv refcount: Refcount,
|
||||
priv read_access: Access,
|
||||
priv write_access: Access,
|
||||
refcount: Refcount,
|
||||
read_access: Access,
|
||||
write_access: Access,
|
||||
}
|
||||
|
||||
impl UdpWatcher {
|
||||
|
|
|
@ -26,19 +26,19 @@ use uvll;
|
|||
pub struct PipeWatcher {
|
||||
stream: StreamWatcher,
|
||||
home: HomeHandle,
|
||||
priv defused: bool,
|
||||
priv refcount: Refcount,
|
||||
defused: bool,
|
||||
refcount: Refcount,
|
||||
|
||||
// see comments in TcpWatcher for why these exist
|
||||
priv write_access: Access,
|
||||
priv read_access: Access,
|
||||
write_access: Access,
|
||||
read_access: Access,
|
||||
}
|
||||
|
||||
pub struct PipeListener {
|
||||
home: HomeHandle,
|
||||
pipe: *uvll::uv_pipe_t,
|
||||
priv outgoing: Sender<Result<~RtioPipe:Send, IoError>>,
|
||||
priv incoming: Receiver<Result<~RtioPipe:Send, IoError>>,
|
||||
outgoing: Sender<Result<~RtioPipe:Send, IoError>>,
|
||||
incoming: Receiver<Result<~RtioPipe:Send, IoError>>,
|
||||
}
|
||||
|
||||
pub struct PipeAcceptor {
|
||||
|
|
|
@ -46,13 +46,13 @@ struct State {
|
|||
/// This structure is intended to be stored next to the event loop, and it is
|
||||
/// used to create new `Queue` structures.
|
||||
pub struct QueuePool {
|
||||
priv queue: UnsafeArc<State>,
|
||||
priv refcnt: uint,
|
||||
queue: UnsafeArc<State>,
|
||||
refcnt: uint,
|
||||
}
|
||||
|
||||
/// This type is used to send messages back to the original event loop.
|
||||
pub struct Queue {
|
||||
priv queue: UnsafeArc<State>,
|
||||
queue: UnsafeArc<State>,
|
||||
}
|
||||
|
||||
extern fn async_cb(handle: *uvll::uv_async_t, status: c_int) {
|
||||
|
|
|
@ -19,7 +19,7 @@
|
|||
use std::sync::arc::UnsafeArc;
|
||||
|
||||
pub struct Refcount {
|
||||
priv rc: UnsafeArc<uint>,
|
||||
rc: UnsafeArc<uint>,
|
||||
}
|
||||
|
||||
impl Refcount {
|
||||
|
|
|
@ -23,13 +23,13 @@ use uvll;
|
|||
// uv_stream_t instance, and all I/O operations assume that it's already located
|
||||
// on the appropriate scheduler.
|
||||
pub struct StreamWatcher {
|
||||
handle: *uvll::uv_stream_t,
|
||||
pub handle: *uvll::uv_stream_t,
|
||||
|
||||
// Cache the last used uv_write_t so we don't have to allocate a new one on
|
||||
// every call to uv_write(). Ideally this would be a stack-allocated
|
||||
// structure, but currently we don't have mappings for all the structures
|
||||
// defined in libuv, so we're foced to malloc this.
|
||||
priv last_write_req: Option<Request>,
|
||||
last_write_req: Option<Request>,
|
||||
}
|
||||
|
||||
struct ReadContext {
|
||||
|
|
|
@ -46,7 +46,7 @@ use uvll;
|
|||
|
||||
// Obviously an Event Loop is always home.
|
||||
pub struct UvEventLoop {
|
||||
priv uvio: UvIoFactory
|
||||
uvio: UvIoFactory
|
||||
}
|
||||
|
||||
impl UvEventLoop {
|
||||
|
@ -124,8 +124,8 @@ fn test_callback_run_once() {
|
|||
}
|
||||
|
||||
pub struct UvIoFactory {
|
||||
loop_: Loop,
|
||||
priv handle_pool: Option<~QueuePool>,
|
||||
pub loop_: Loop,
|
||||
handle_pool: Option<~QueuePool>,
|
||||
}
|
||||
|
||||
impl UvIoFactory {
|
||||
|
|
|
@ -100,15 +100,15 @@ pub type uv_buf_len_t = libc::c_ulong;
|
|||
// see libuv/include/uv-unix.h
|
||||
#[cfg(unix)]
|
||||
pub struct uv_buf_t {
|
||||
base: *u8,
|
||||
len: uv_buf_len_t,
|
||||
pub base: *u8,
|
||||
pub len: uv_buf_len_t,
|
||||
}
|
||||
|
||||
// see libuv/include/uv-win.h
|
||||
#[cfg(windows)]
|
||||
pub struct uv_buf_t {
|
||||
len: uv_buf_len_t,
|
||||
base: *u8,
|
||||
pub len: uv_buf_len_t,
|
||||
pub base: *u8,
|
||||
}
|
||||
|
||||
#[repr(C)]
|
||||
|
@ -119,23 +119,23 @@ pub enum uv_run_mode {
|
|||
}
|
||||
|
||||
pub struct uv_process_options_t {
|
||||
exit_cb: uv_exit_cb,
|
||||
file: *libc::c_char,
|
||||
args: **libc::c_char,
|
||||
env: **libc::c_char,
|
||||
cwd: *libc::c_char,
|
||||
flags: libc::c_uint,
|
||||
stdio_count: libc::c_int,
|
||||
stdio: *uv_stdio_container_t,
|
||||
uid: uv_uid_t,
|
||||
gid: uv_gid_t,
|
||||
pub exit_cb: uv_exit_cb,
|
||||
pub file: *libc::c_char,
|
||||
pub args: **libc::c_char,
|
||||
pub env: **libc::c_char,
|
||||
pub cwd: *libc::c_char,
|
||||
pub flags: libc::c_uint,
|
||||
pub stdio_count: libc::c_int,
|
||||
pub stdio: *uv_stdio_container_t,
|
||||
pub uid: uv_uid_t,
|
||||
pub gid: uv_gid_t,
|
||||
}
|
||||
|
||||
// These fields are private because they must be interfaced with through the
|
||||
// functions below.
|
||||
pub struct uv_stdio_container_t {
|
||||
priv flags: libc::c_int,
|
||||
priv stream: *uv_stream_t,
|
||||
flags: libc::c_int,
|
||||
stream: *uv_stream_t,
|
||||
}
|
||||
|
||||
pub type uv_handle_t = c_void;
|
||||
|
@ -160,27 +160,27 @@ pub type uv_signal_t = c_void;
|
|||
pub type uv_shutdown_t = c_void;
|
||||
|
||||
pub struct uv_timespec_t {
|
||||
tv_sec: libc::c_long,
|
||||
tv_nsec: libc::c_long
|
||||
pub tv_sec: libc::c_long,
|
||||
pub tv_nsec: libc::c_long
|
||||
}
|
||||
|
||||
pub struct uv_stat_t {
|
||||
st_dev: libc::uint64_t,
|
||||
st_mode: libc::uint64_t,
|
||||
st_nlink: libc::uint64_t,
|
||||
st_uid: libc::uint64_t,
|
||||
st_gid: libc::uint64_t,
|
||||
st_rdev: libc::uint64_t,
|
||||
st_ino: libc::uint64_t,
|
||||
st_size: libc::uint64_t,
|
||||
st_blksize: libc::uint64_t,
|
||||
st_blocks: libc::uint64_t,
|
||||
st_flags: libc::uint64_t,
|
||||
st_gen: libc::uint64_t,
|
||||
st_atim: uv_timespec_t,
|
||||
st_mtim: uv_timespec_t,
|
||||
st_ctim: uv_timespec_t,
|
||||
st_birthtim: uv_timespec_t
|
||||
pub st_dev: libc::uint64_t,
|
||||
pub st_mode: libc::uint64_t,
|
||||
pub st_nlink: libc::uint64_t,
|
||||
pub st_uid: libc::uint64_t,
|
||||
pub st_gid: libc::uint64_t,
|
||||
pub st_rdev: libc::uint64_t,
|
||||
pub st_ino: libc::uint64_t,
|
||||
pub st_size: libc::uint64_t,
|
||||
pub st_blksize: libc::uint64_t,
|
||||
pub st_blocks: libc::uint64_t,
|
||||
pub st_flags: libc::uint64_t,
|
||||
pub st_gen: libc::uint64_t,
|
||||
pub st_atim: uv_timespec_t,
|
||||
pub st_mtim: uv_timespec_t,
|
||||
pub st_ctim: uv_timespec_t,
|
||||
pub st_birthtim: uv_timespec_t
|
||||
}
|
||||
|
||||
impl uv_stat_t {
|
||||
|
|
Loading…
Add table
Reference in a new issue