2010-07-28 16:46:13 -07:00
|
|
|
#ifndef RUST_PORT_H
|
|
|
|
#define RUST_PORT_H
|
|
|
|
|
2012-04-02 22:18:01 -05:00
|
|
|
#include "rust_globals.h"
|
|
|
|
#include "circular_buffer.h"
|
2012-02-14 22:23:16 -08:00
|
|
|
|
2012-03-04 16:52:19 -08:00
|
|
|
class port_detach_cond : public rust_cond { };
|
|
|
|
|
2011-07-29 11:00:44 -07:00
|
|
|
class rust_port : public kernel_owned<rust_port>, public rust_cond {
|
2012-03-06 15:31:21 -08:00
|
|
|
private:
|
|
|
|
// Protects ref_count and detach_cond
|
|
|
|
lock_and_signal ref_lock;
|
|
|
|
intptr_t ref_count;
|
|
|
|
port_detach_cond detach_cond;
|
|
|
|
|
2010-07-28 16:46:13 -07:00
|
|
|
public:
|
2012-03-06 15:31:21 -08:00
|
|
|
void ref();
|
|
|
|
void deref();
|
2011-07-29 11:00:44 -07:00
|
|
|
|
2012-03-06 15:31:21 -08:00
|
|
|
public:
|
2011-08-08 18:09:42 -07:00
|
|
|
rust_port_id id;
|
|
|
|
|
2011-07-07 11:53:08 -07:00
|
|
|
rust_kernel *kernel;
|
2010-07-28 16:46:13 -07:00
|
|
|
rust_task *task;
|
|
|
|
size_t unit_sz;
|
2011-11-11 11:46:07 -08:00
|
|
|
circular_buffer buffer;
|
2010-07-28 16:46:13 -07:00
|
|
|
|
2011-07-07 11:53:08 -07:00
|
|
|
lock_and_signal lock;
|
|
|
|
|
2012-03-04 16:52:19 -08:00
|
|
|
public:
|
2010-07-28 16:46:13 -07:00
|
|
|
rust_port(rust_task *task, size_t unit_sz);
|
|
|
|
~rust_port();
|
2012-03-04 15:36:32 -08:00
|
|
|
|
2010-08-09 07:52:07 -07:00
|
|
|
void log_state();
|
2011-11-10 17:53:19 -08:00
|
|
|
void send(void *sptr);
|
2012-03-02 00:55:27 -08:00
|
|
|
void receive(void *dptr, uintptr_t *yield);
|
2011-11-13 15:28:59 -08:00
|
|
|
size_t size();
|
2012-03-04 16:52:19 -08:00
|
|
|
|
|
|
|
void begin_detach(uintptr_t *yield);
|
|
|
|
void end_detach();
|
2010-07-28 16:46:13 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
//
|
|
|
|
// Local Variables:
|
|
|
|
// mode: C++
|
|
|
|
// fill-column: 78;
|
|
|
|
// indent-tabs-mode: nil
|
|
|
|
// c-basic-offset: 4
|
|
|
|
// buffer-file-coding-system: utf-8-unix
|
2011-07-13 13:51:20 -07:00
|
|
|
// compile-command: "make -k -C $RBUILD 2>&1 | sed -e 's/\\/x\\//x:\\//g'";
|
2010-07-28 16:46:13 -07:00
|
|
|
// End:
|
|
|
|
//
|
|
|
|
|
|
|
|
#endif /* RUST_PORT_H */
|