add needed fields for global libuv loop + bindings to manage from rust
adding two pointers fields to rust_kernel :( .. have to do manual malloc/free for one of the fields, which feels wrong
This commit is contained in:
parent
bf99a3aa93
commit
c6667c06c3
@ -24,6 +24,13 @@ rust_kernel::rust_kernel(rust_env *env) :
|
||||
non_weak_tasks(0),
|
||||
env(env)
|
||||
{
|
||||
// set up storage of pointers needed to
|
||||
// access the global loop.
|
||||
global_loop_chan = 0;
|
||||
global_async_handle = (void**)::malloc( // FIXME -- can use this->malloc()
|
||||
sizeof(void*)); // .. what do?
|
||||
*global_async_handle = (void*)0;
|
||||
|
||||
// Create the single threaded scheduler that will run on the platform's
|
||||
// main thread
|
||||
rust_manual_sched_launcher_factory launchfac;
|
||||
|
@ -73,6 +73,10 @@ class rust_kernel {
|
||||
rust_scheduler* get_scheduler_by_id_nolock(rust_sched_id id);
|
||||
void end_weak_tasks();
|
||||
|
||||
// Used to communicate with the process-side, global libuv loop
|
||||
uintptr_t global_loop_chan;
|
||||
void** global_async_handle;
|
||||
|
||||
public:
|
||||
struct rust_env *env;
|
||||
|
||||
@ -117,6 +121,11 @@ public:
|
||||
void unweaken_task(rust_port_id chan);
|
||||
|
||||
bool send_to_port(rust_port_id chan, void *sptr);
|
||||
|
||||
uintptr_t* get_global_loop() { return &global_loop_chan; }
|
||||
void** get_global_async_handle() { return global_async_handle; }
|
||||
void set_global_async_handle(void* handle) {
|
||||
*global_async_handle = handle; }
|
||||
};
|
||||
|
||||
template <typename T> struct kernel_owned {
|
||||
|
@ -425,3 +425,24 @@ rust_uv_ip4_addr(const char* ip, int port) {
|
||||
LOG(task, stdlib, "after creating .. port: %d\n", addr.sin_port);
|
||||
return addr;
|
||||
}
|
||||
|
||||
extern "C" uintptr_t*
|
||||
rust_uv_get_kernel_global_chan_ptr() {
|
||||
uintptr_t* result = rust_get_current_task()->kernel->get_global_loop();
|
||||
printf("global loop: %lu\n", (unsigned long int)result);
|
||||
printf("global loop val: %lu\n", (unsigned long int)*result);
|
||||
return result;
|
||||
}
|
||||
|
||||
extern "C" void**
|
||||
rust_uv_get_kernel_global_async_handle() {
|
||||
return rust_get_current_task()->kernel->get_global_async_handle();
|
||||
}
|
||||
extern "C" void
|
||||
rust_uv_set_kernel_global_async_handle(uv_async_t* handle) {
|
||||
rust_get_current_task()->kernel->set_global_async_handle((void*)handle);
|
||||
}
|
||||
extern "C" void
|
||||
rust_uv_free_kernel_global_async_handle() {
|
||||
free((void*)rust_get_current_task()->kernel->get_global_async_handle());
|
||||
}
|
||||
|
@ -134,6 +134,10 @@ rust_uv_get_data_for_req
|
||||
rust_uv_set_data_for_req
|
||||
rust_uv_get_base_from_buf
|
||||
rust_uv_get_len_from_buf
|
||||
rust_uv_get_kernel_global_chan_ptr
|
||||
rust_uv_get_kernel_global_async_handle
|
||||
rust_uv_set_kernel_global_async_handle
|
||||
rust_uv_free_kernel_global_async_handle
|
||||
rust_dbg_lock_create
|
||||
rust_dbg_lock_destroy
|
||||
rust_dbg_lock_lock
|
||||
|
Loading…
x
Reference in New Issue
Block a user