Graydon Hoare | d1affff | 2012-12-11 01:32:48 | [diff] [blame] | 1 | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT |
2 | // file at the top-level directory of this distribution and at | ||||
3 | // http://rust-lang.org/COPYRIGHT. | ||||
4 | // | ||||
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | ||||
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | ||||
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | ||||
8 | // option. This file may not be copied, modified, or distributed | ||||
9 | // except according to those terms. | ||||
10 | |||||
Corey Richardson | dee1107 | 2013-12-17 21:40:33 | [diff] [blame] | 11 | #[crate_id="issue_2526#0.2"]; |
Tim Chevalier | 6f95c79 | 2012-06-13 18:20:21 | [diff] [blame] | 12 | #[crate_type = "lib"]; |
13 | |||||
Patrick Walton | 1be40be | 2013-05-21 00:07:24 | [diff] [blame] | 14 | extern mod extra; |
Tim Chevalier | 6f95c79 | 2012-06-13 18:20:21 | [diff] [blame] | 15 | |
Patrick Walton | 6ce7446 | 2013-01-28 18:46:43 | [diff] [blame] | 16 | struct arc_destruct<T> { |
Brian Anderson | 2572e80 | 2012-09-07 02:40:15 | [diff] [blame] | 17 | _data: int, |
Ben Striegel | f4a5a76 | 2012-11-14 06:22:37 | [diff] [blame] | 18 | } |
19 | |||||
Patrick Walton | d4fee24 | 2013-03-21 01:18:57 | [diff] [blame] | 20 | #[unsafe_destructor] |
Patrick Walton | 1eec3bb | 2013-06-05 22:53:17 | [diff] [blame] | 21 | impl<T:Freeze> Drop for arc_destruct<T> { |
Daniel Micay | 4e161a4 | 2013-09-17 01:18:07 | [diff] [blame] | 22 | fn drop(&mut self) {} |
Tim Chevalier | 588c1eb | 2012-06-22 20:11:29 | [diff] [blame] | 23 | } |
Tim Chevalier | 6f95c79 | 2012-06-13 18:20:21 | [diff] [blame] | 24 | |
Patrick Walton | 1eec3bb | 2013-06-05 22:53:17 | [diff] [blame] | 25 | fn arc_destruct<T:Freeze>(data: int) -> arc_destruct<T> { |
Brian Anderson | b4e547d | 2012-09-05 22:58:43 | [diff] [blame] | 26 | arc_destruct { |
27 | _data: data | ||||
28 | } | ||||
29 | } | ||||
30 | |||||
Patrick Walton | 1eec3bb | 2013-06-05 22:53:17 | [diff] [blame] | 31 | fn arc<T:Freeze>(_data: T) -> arc_destruct<T> { |
Tim Chevalier | 6f95c79 | 2012-06-13 18:20:21 | [diff] [blame] | 32 | arc_destruct(0) |
33 | } | ||||
34 | |||||
Graydon Hoare | 721c174 | 2013-01-24 00:28:10 | [diff] [blame] | 35 | fn init() -> arc_destruct<context_res> { |
Erick Tryzelaar | ad5c676 | 2013-08-17 15:37:42 | [diff] [blame] | 36 | arc(context_res()) |
Tim Chevalier | 6f95c79 | 2012-06-13 18:20:21 | [diff] [blame] | 37 | } |
38 | |||||
Brian Anderson | 3ab4b01 | 2012-08-16 01:46:55 | [diff] [blame] | 39 | struct context_res { |
Brian Anderson | 2572e80 | 2012-09-07 02:40:15 | [diff] [blame] | 40 | ctx : int, |
Ben Striegel | f4a5a76 | 2012-11-14 06:22:37 | [diff] [blame] | 41 | } |
Tim Chevalier | 6f95c79 | 2012-06-13 18:20:21 | [diff] [blame] | 42 | |
Patrick Walton | 9143688 | 2013-02-14 19:47:00 | [diff] [blame] | 43 | impl Drop for context_res { |
Daniel Micay | 4e161a4 | 2013-09-17 01:18:07 | [diff] [blame] | 44 | fn drop(&mut self) {} |
Tim Chevalier | 6f95c79 | 2012-06-13 18:20:21 | [diff] [blame] | 45 | } |
46 | |||||
Brian Anderson | b4e547d | 2012-09-05 22:58:43 | [diff] [blame] | 47 | fn context_res() -> context_res { |
48 | context_res { | ||||
49 | ctx: 0 | ||||
50 | } | ||||
51 | } | ||||
52 | |||||
Patrick Walton | 49472ec | 2013-01-31 01:20:02 | [diff] [blame] | 53 | pub type context = arc_destruct<context_res>; |