mirror of
https://github.com/vlang/v.git
synced 2025-09-13 22:42:26 +03:00
coroutines: use photon work_pool when nr_jobs > 0, and use photon libc fn wrappers (#19711)
This commit is contained in:
parent
57a7db11bf
commit
a63f3e6f77
7 changed files with 122 additions and 12 deletions
25
thirdparty/photon/photonwrapper.h
vendored
25
thirdparty/photon/photonwrapper.h
vendored
|
@ -1,6 +1,8 @@
|
|||
#ifndef C_PHOTONWRAPPER_H_
|
||||
#define C_PHOTONWRAPPER_H_
|
||||
|
||||
#include <sys/socket.h>
|
||||
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
||||
|
@ -12,23 +14,42 @@
|
|||
#include <photon/common/iovector.h>
|
||||
#include <photon/fs/localfs.h>
|
||||
#include <photon/net/socket.h>
|
||||
|
||||
#include <photon/net/basic_socket.h>
|
||||
#include <photon/thread/workerpool.h>
|
||||
#include <iostream>
|
||||
|
||||
extern "C" {
|
||||
// using namespace photon;
|
||||
// WorkPool* work_pool;
|
||||
// WorkPool* new_photon_work_pool();
|
||||
photon::WorkPool* work_pool;
|
||||
#else
|
||||
|
||||
#endif
|
||||
|
||||
// custom v functions
|
||||
void init_photon_work_pool(size_t);
|
||||
void photon_thread_create_and_migrate_to_work_pool(void* (* f)(void*), void* arg);
|
||||
// direct wrappers to photon functions
|
||||
int photon_init_default();
|
||||
void photon_thread_create(void* (* f)(void*), void* arg);
|
||||
void photon_sleep_s(int n);
|
||||
void photon_sleep_ms(int n);
|
||||
|
||||
// void* default_photon_thread_stack_alloc(void*, size_t size);
|
||||
// void default_photon_thread_stack_dealloc(void*, void* ptr, size_t size);
|
||||
void set_photon_thread_stack_allocator(
|
||||
void* (*alloc_func)(void*, size_t),
|
||||
void (*dealloc_func)(void*, void*, size_t)
|
||||
);
|
||||
|
||||
int photon_socket(int domain, int type, int protocol);
|
||||
int photon_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, uint64_t timeout);
|
||||
int photon_accept(int fd, struct sockaddr *addr, socklen_t *addrlen, uint64_t timeout);
|
||||
ssize_t photon_send(int fd, const void* buf, size_t len, int flags, uint64_t timeout);
|
||||
// ssize_t photon_sendmsg(int fd, const struct msghdr* msg, int flags, uint64_t timeout);
|
||||
ssize_t photon_recv(int fd, void* buf, size_t count, int flags, uint64_t timeout);
|
||||
// ssize_t photon_recvmsg(int fd, struct msghdr* msg, int flags, uint64_t timeout);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue