aboutsummaryrefslogtreecommitdiff
path: root/src/rt/rust_proxy.h
blob: 8059dd89d42039e82c9e79026dbe029bdb64c893 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
/**
 * 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.
 */

#ifndef RUST_PROXY_H
#define RUST_PROXY_H

template <typename T> struct
rust_proxy_delegate : public rc_base<T> {
protected:
    T *_delegate;
public:
    rust_proxy_delegate(T * delegate) : _delegate(delegate) {
    }
    T *delegate() { return _delegate; }
};

template <typename T> struct
rust_proxy : public rust_proxy_delegate<T>,
             public dom_owned<rust_proxy<T> > {
public:
    rust_dom *dom;
    rust_proxy(rust_dom *dom, T *delegate) :
        rust_proxy_delegate<T> (delegate),
        dom(dom) {
        delegate->ref();
    }
};

#endif /* RUST_PROXY_H */