v / thirdparty / photon / photonwrapper.h
71 lines · 57 sloc · 2.18 KB · f3156768826830d9977a419fc89ea28cece72807
Raw
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
21extern "C" {
22
23// WorkPool* work_pool;
24photon::WorkPool* work_pool;
25
26// using namespace photon;
27// typedef WorkPool PhotonWorkPool;
28// typedef photon::WorkPool PhotonWorkPool1;
29#else
30#endif
31
32void* new_photon_work_pool(size_t);
33// void delete_photon_work_pool(void*);
34void delete_photon_work_pool();
35// custom v functions
36void init_photon_work_pool(size_t);
37// void photon_thread_migrate();
38// void photon_thread_migrate(void*);
39void 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);
41int photon_join_current_thread_into_workpool();
42void photon_set_log_output_stdout();
43void photon_set_log_output_stderr();
44void photon_set_log_output_null();
45// direct wrappers to photon functions
46int photon_init_default();
47void photon_thread_create(void* (* f)(void*), void* arg);
48void photon_sleep_s(int n);
49void photon_sleep_ms(int n);
50
51void* default_photon_thread_stack_alloc(void*, size_t size);
52void default_photon_thread_stack_dealloc(void*, void* ptr, size_t size);
53void set_photon_thread_stack_allocator(
54 void* (*alloc_func)(void*, size_t),
55 void (*dealloc_func)(void*, void*, size_t)
56);
57
58int photon_socket(int domain, int type, int protocol);
59int photon_connect(int fd, const struct sockaddr *addr, socklen_t addrlen, uint64_t timeout);
60int photon_accept(int fd, struct sockaddr *addr, socklen_t *addrlen, uint64_t timeout);
61ssize_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);
63ssize_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