PageRenderTime 11ms CodeModel.GetById 1ms app.highlight 6ms RepoModel.GetById 1ms app.codeStats 1ms

/src/rt/rust_port.h

http://github.com/jruderman/rust
C Header | 54 lines | 31 code | 12 blank | 11 comment | 0 complexity | 19b4d075e312d7e15b8cd58ad677f55e MD5 | raw file
 1#ifndef RUST_PORT_H
 2#define RUST_PORT_H
 3
 4#include "rust_globals.h"
 5#include "circular_buffer.h"
 6
 7class port_detach_cond : public rust_cond { };
 8
 9class rust_port : public kernel_owned<rust_port>, public rust_cond {
10private:
11    // Protects ref_count and detach_cond
12    lock_and_signal ref_lock;
13    intptr_t ref_count;
14    port_detach_cond detach_cond;
15
16public:
17    void ref();
18    void deref();
19
20public:
21    rust_port_id id;
22
23    rust_kernel *kernel;
24    rust_task *task;
25    size_t unit_sz;
26    circular_buffer buffer;
27
28    lock_and_signal lock;
29
30public:
31    rust_port(rust_task *task, size_t unit_sz);
32    ~rust_port();
33
34    void log_state();
35    void send(void *sptr);
36    void receive(void *dptr, uintptr_t *yield);
37    size_t size();
38
39    void begin_detach(uintptr_t *yield);
40    void end_detach();
41};
42
43//
44// Local Variables:
45// mode: C++
46// fill-column: 78;
47// indent-tabs-mode: nil
48// c-basic-offset: 4
49// buffer-file-coding-system: utf-8-unix
50// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
51// End:
52//
53
54#endif /* RUST_PORT_H */