| 1 | #ifndef C_PHOTONWRAPPER_H_ |
| 2 | #define C_PHOTONWRAPPER_H_ |
| 3 | |
| 4 | #include <sys/socket.h> |
| 5 | |
| 6 | |
| 7 | #ifdef __cplusplus |
| 8 | |
| 9 | #include <fcntl.h> |
| 10 | //#include <vector> |
| 11 | |
| 12 | #include <photon/thread/std-compat.h> |
| 13 | #include <photon/common/alog.h> |
| 14 | #include <photon/common/iovector.h> |
| 15 | #include <photon/fs/localfs.h> |
| 16 | #include <photon/net/socket.h> |
| 17 | #include <photon/net/basic_socket.h> |
| 18 | #include <photon/thread/workerpool.h> |
| 19 | #include <iostream> |
| 20 | |
| 21 | extern "C" { |
| 22 | |
| 23 | // WorkPool* work_pool; |
| 24 | photon::WorkPool* work_pool; |
| 25 | |
| 26 | // using namespace photon; |
| 27 | // typedef WorkPool PhotonWorkPool; |
| 28 | // typedef photon::WorkPool PhotonWorkPool1; |
| 29 | #else |
| 30 | #endif |
| 31 | |
| 32 | void* new_photon_work_pool(size_t); |
| 33 | // void delete_photon_work_pool(void*); |
| 34 | void delete_photon_work_pool(); |
| 35 | // custom v functions |
| 36 | void init_photon_work_pool(size_t); |
| 37 | // void photon_thread_migrate(); |
| 38 | // void photon_thread_migrate(void*); |
| 39 | void photon_thread_create_and_migrate_to_work_pool(void* (* f)(void*), void* arg); |
| 40 | // void photon_thread_create_and_migrate_to_work_pool(void*, void* (* f)(void*), void* arg); |
| 41 | int photon_join_current_thread_into_workpool(); |
| 42 | void photon_set_log_output_stdout(); |
| 43 | void photon_set_log_output_stderr(); |
| 44 | void photon_set_log_output_null(); |
| 45 | // direct wrappers to photon functions |
| 46 | int photon_init_default(); |
| 47 | void photon_thread_create(void* (* f)(void*), void* arg); |
| 48 | void photon_sleep_s(int n); |
| 49 | void photon_sleep_ms(int n); |
| 50 | |
| 51 | void* default_photon_thread_stack_alloc(void*, size_t size); |
| 52 | void default_photon_thread_stack_dealloc(void*, void* ptr, size_t size); |
| 53 | void set_photon_thread_stack_allocator( |
| 54 | void* (*alloc_func)(void*, size_t), |
| 55 | void (*dealloc_func)(void*, void*, size_t) |
| 56 | ); |
| 57 | |
| 58 | int photon_socket(int domain, int type, int protocol); |
| 59 | int photon_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, uint64_t timeout); |
| 60 | int photon_accept(int fd, struct sockaddr *addr, socklen_t *addrlen, uint64_t timeout); |
| 61 | ssize_t photon_send(int fd, const void* buf, size_t len, int flags, uint64_t timeout); |
| 62 | // ssize_t photon_sendmsg(int fd, const struct msghdr* msg, int flags, uint64_t timeout); |
| 63 | ssize_t photon_recv(int fd, void* buf, size_t count, int flags, uint64_t timeout); |
| 64 | // ssize_t photon_recvmsg(int fd, struct msghdr* msg, int flags, uint64_t timeout); |
| 65 | |
| 66 | #ifdef __cplusplus |
| 67 | } |
| 68 | #endif |
| 69 | |
| 70 | |
| 71 | #endif |
| 72 | |