aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_proxy.h
diff options
context:
space:
mode:
authorMichael Bebenita <[email protected]>2010-09-07 18:39:07 -0700
committerMichael Bebenita <[email protected]>2010-09-07 18:44:12 -0700
commitde611a309006f0976bc9a579eb1087e7a89f79a7 (patch)
treecd30b33ab1986c0cc84e0fc0743593bd99b0caaa /src/rt/rust_proxy.h
parentStarted work on a framework for writing runtime tests, added some simple test... (diff)
downloadrust-de611a309006f0976bc9a579eb1087e7a89f79a7.tar.xz
rust-de611a309006f0976bc9a579eb1087e7a89f79a7.zip
Lots of design changes around proxies and message passing. Made it so that domains can only talk to other domains via handles, and with the help of the rust_kernel.
Diffstat (limited to 'src/rt/rust_proxy.h')
-rw-r--r--src/rt/rust_proxy.h53
1 files changed, 33 insertions, 20 deletions
diff --git a/src/rt/rust_proxy.h b/src/rt/rust_proxy.h
index bf12e1d5..2b5e820d 100644
--- a/src/rt/rust_proxy.h
+++ b/src/rt/rust_proxy.h
@@ -2,57 +2,70 @@
#define RUST_PROXY_H
/**
- * A proxy object is a wrapper around other Rust objects. One use of the proxy
- * object is to mitigate access between tasks in different thread domains.
+ * A proxy object is a wrapper for remote objects. Proxy objects are domain
+ * owned and provide a way distinguish between local and remote objects.
*/
template <typename T> struct rust_proxy;
+
/**
* The base class of all objects that may delegate.
*/
template <typename T> struct
maybe_proxy : public rc_base<T>, public rust_cond {
protected:
- T *_delegate;
+ T *_referent;
public:
- maybe_proxy(T * delegate) : _delegate(delegate) {
-
+ maybe_proxy(T *referent) : _referent(referent) {
+ // Nop.
}
- T *delegate() {
- return _delegate;
+
+ T *referent() {
+ return (T *)_referent;
}
+
bool is_proxy() {
- return _delegate != this;
+ return _referent != this;
}
+
rust_proxy<T> *as_proxy() {
return (rust_proxy<T> *) this;
}
- T *as_delegate() {
- I(_delegate->get_dom(), !is_proxy());
+
+ T *as_referent() {
return (T *) this;
}
};
+template <typename T> class rust_handle;
+
/**
* A proxy object that delegates to another.
*/
template <typename T> struct
-rust_proxy : public maybe_proxy<T>,
- public dom_owned<rust_proxy<T> > {
+rust_proxy : public maybe_proxy<T> {
private:
bool _strong;
+ rust_handle<T> *_handle;
public:
- rust_dom *dom;
- rust_proxy(rust_dom *dom, T *delegate, bool strong) :
- maybe_proxy<T> (delegate), _strong(strong), dom(dom) {
- this->dom->log(rust_log::COMM,
- "new proxy: 0x%" PRIxPTR " => 0x%" PRIxPTR, this, delegate);
- if (strong) {
- delegate->ref();
- }
+ rust_proxy(rust_handle<T> *handle) :
+ maybe_proxy<T> (NULL), _strong(FALSE), _handle(handle) {
+ // Nop.
+ }
+
+ rust_proxy(T *referent) :
+ maybe_proxy<T> (referent), _strong(FALSE), _handle(NULL) {
+ // Nop.
+ }
+
+ rust_handle<T> *handle() {
+ return _handle;
}
};
+class rust_message_queue;
+class rust_task;
+
//
// Local Variables:
// mode: C++