You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@graydon and I were talking on IRC about using conditions for serializations error handling today. He convinced me to try out using subtasks to parse and catch failures, but unfortunately doing this means that we can't use serialization error handling on types with managed pointers.
This problem would go away if we could somehow move managed pointers from task A to task B. Even though it's generally unsafe to send a managed pointer across tasks, it's theoretically safe if it's the last thing a task does before it dies.
Here's an obviously wrong, only-works-for-ints example function:
fn try_managed<T>(f: fn~() -> @T) -> Result<@T, ()> {
let result: Result<*libc::c_void, ()> = do task::try {
unsafe {
let v = f();
cast::forget(v);
cast::reinterpret_cast::<@T, *libc::c_void>(&v)
}
};
match move result {
Ok(move v) => {
unsafe {
let v = cast::reinterpret_cast::<*libc::c_void, @T>(&v);
cast::bump_box_refcount(v);
Ok(move v)
}
}
Err(move e) => Err(e),
}
}
fn main() {
let r = do try_managed {
@5
};
match r {
Err(_) => io::println("err"),
Ok(x) => io::println(fmt!("%?", *x)),
}
}
It segfaults for more complicated data structures, like ~strs.
The text was updated successfully, but these errors were encountered:
@pcwalton has been talking about adding something which would permit @ to be sent across tasks by serializing and deserializing them. Essentially, cloning them, just as Erlang does. This would be a simpler addition (no language changes at all) though it'd likely not be as efficient.
Keep in mind that while @ pointers will not be aliased if sent as part of the "last thing the task does", however we define that, it may still require some kind of cleverness in the garbage collector and so forth, depending on how we ultimately implement @ pointers.
So I guess I'm...unsure about this idea, but not completely opposed.
epoll: Add a EINVAL case
In ``epoll_ctl`` documentation, it is mentioned that:
> EINVAL epfd is not an epoll file descriptor, or fd is the same as epfd, or the requested operation op is not supported by this interface.
So I added this EINVAL case for ``epfd == fd`` in ``epoll_ctl``
@graydon and I were talking on IRC about using conditions for serializations error handling today. He convinced me to try out using subtasks to parse and catch failures, but unfortunately doing this means that we can't use serialization error handling on types with managed pointers.
This problem would go away if we could somehow move managed pointers from task A to task B. Even though it's generally unsafe to send a managed pointer across tasks, it's theoretically safe if it's the last thing a task does before it dies.
Here's an obviously wrong, only-works-for-ints example function:
It segfaults for more complicated data structures, like
~str
s.The text was updated successfully, but these errors were encountered: