本文整理汇总了C++中port_create函数的典型用法代码示例。如果您正苦于以下问题:C++ port_create函数的具体用法?C++ port_create怎么用?C++ port_create使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了port_create函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: fShowLevel
Window::Window(long left, long top, long right, long bottom)
: fShowLevel(0),
fCanvasList(0)
{
int windowServerPort;
windowServerPort = namer_find ("window_server", 0);
if (windowServerPort <= 0) {
printf("couldn't connect to window server\n");
return;
}
int localReplyPort = port_create(0, "client_syncport");
fEventPort = port_create(0, "client_eventport");
fConnection = new Connection(windowServerPort, localReplyPort);
fConnection->WriteInt8(OP_CREATE_WINDOW);
fConnection->WriteInt32(0); // Child of root window
fConnection->WriteInt32(left);
fConnection->WriteInt32(top);
fConnection->WriteInt32(right);
fConnection->WriteInt32(bottom);
fConnection->WriteInt32(fEventPort);
fConnection->Flush();
fID = fConnection->ReadInt32();
fLock = qsem_create(1);
thr_create((void*) EventLoop, this, "win_thread");
}
开发者ID:danilaslau,项目名称:frotznet,代码行数:29,代码来源:Window.cpp
示例2: evport_init
static void*
evport_init(struct event_base *base)
{
struct evport_data *evpd;
if (!(evpd = mm_calloc(1, sizeof(struct evport_data))))
return (NULL);
if ((evpd->ed_port = port_create()) == -1) {
mm_free(evpd);
return (NULL);
}
if (grow(evpd, INITIAL_EVENTS_PER_GETN) < 0) {
close(evpd->ed_port);
mm_free(evpd);
return NULL;
}
evpd->ed_npending = 0;
evsig_init_(base);
return (evpd);
}
开发者ID:TomCN7,项目名称:Event,代码行数:25,代码来源:evport.c
示例3: defined
void SelEpolKqEvPrt::initialize(SOCKET sockfd, const int& timeout)
{
this->timeoutMilis = timeout;
this->sockfd = sockfd;
if(sockfd<=0)
{
listenerMode = false;
sockfd = 0;
}
else
{
listenerMode = true;
}
curfds = 1;
#if defined(USE_WIN_IOCP)
initIOCP();
#elif defined(USE_MINGW_SELECT)
fdMax = sockfd;
FD_ZERO(&readfds);
FD_ZERO(&master);
#elif defined(USE_SELECT)
fdsetSize = MAXDESCRIPTORS/FD_SETSIZE;
fdMax = sockfd;
for (int var = 0; var < fdsetSize; ++var) {
FD_ZERO(&readfds[var]);
FD_ZERO(&master[var]);
}
#elif defined USE_EPOLL
epoll_handle = epoll_create(MAXDESCRIPTORS);
memset(&ev, 0, sizeof(ev));
#elif defined USE_KQUEUE
kq = kqueue();
if (kq == -1)
{
perror("kqueue");
}
#elif defined USE_DEVPOLL
if((dev_poll_fd = open("/dev/poll", O_RDWR)) <0)
{
perror("devpoll");
}
if (fcntl(dev_poll_fd, F_SETFD, FD_CLOEXEC) < 0)
{
perror("devpoll fcntl");
}
#elif defined USE_EVPORT
if ((port = port_create()) < 0) {
perror("port_create");
}
#elif defined USE_POLL
nfds=1;
polled_fds = (struct pollfd *)calloc(1, nfds*sizeof(struct pollfd));
polled_fds->fd = descriptor;
polled_fds->events = POLLIN | POLLPRI;
return;
#endif
#if !defined(USE_WIN_IOCP)
if(sockfd>0)registerForEvent(sockfd);
#endif
}
开发者ID:hornsey,项目名称:ffead-cpp,代码行数:60,代码来源:SelEpolKqEvPrt.cpp
示例4: RTDECL
RTDECL(int) RTFileAioCtxCreate(PRTFILEAIOCTX phAioCtx, uint32_t cAioReqsMax,
uint32_t fFlags)
{
int rc = VINF_SUCCESS;
PRTFILEAIOCTXINTERNAL pCtxInt;
AssertPtrReturn(phAioCtx, VERR_INVALID_POINTER);
AssertReturn(!(fFlags & ~RTFILEAIOCTX_FLAGS_VALID_MASK), VERR_INVALID_PARAMETER);
pCtxInt = (PRTFILEAIOCTXINTERNAL)RTMemAllocZ(sizeof(RTFILEAIOCTXINTERNAL));
if (RT_UNLIKELY(!pCtxInt))
return VERR_NO_MEMORY;
/* Init the event handle. */
pCtxInt->iPort = port_create();
if (RT_LIKELY(pCtxInt->iPort > 0))
{
pCtxInt->fFlags = fFlags;
pCtxInt->u32Magic = RTFILEAIOCTX_MAGIC;
*phAioCtx = (RTFILEAIOCTX)pCtxInt;
}
else
{
RTMemFree(pCtxInt);
rc = RTErrConvertFromErrno(errno);
}
return rc;
}
开发者ID:svn2github,项目名称:virtualbox,代码行数:28,代码来源:fileaio-solaris.cpp
示例5: init_evports_per_thread
static int init_evports_per_thread()
{
int fd;
evports_evlist_max = global.tune.maxpollevents;
evports_evlist = calloc(evports_evlist_max, sizeof (port_event_t));
if (evports_evlist == NULL) {
goto fail_alloc;
}
if (MAX_THREADS > 1 && tid) {
if ((evports_fd[tid] = port_create()) == -1) {
goto fail_fd;
}
}
/* we may have to unregister some events initially registered on the
* original fd when it was alone, and/or to register events on the new
* fd for this thread. Let's just mark them as updated, the poller will
* do the rest.
*/
for (fd = 0; fd < global.maxsock; fd++)
updt_fd_polling(fd);
return 1;
fail_fd:
free(evports_evlist);
evports_evlist = NULL;
evports_evlist_max = 0;
fail_alloc:
return 0;
}
开发者ID:haproxy,项目名称:haproxy,代码行数:33,代码来源:ev_evports.c
示例6: uv_fs_event_init
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb,
int flags) {
int portfd;
loop->counters.fs_event_init++;
/* We don't support any flags yet. */
assert(!flags);
if ((portfd = port_create()) == -1) {
uv__set_sys_error(loop, errno);
return -1;
}
uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
handle->filename = strdup(filename);
handle->fd = portfd;
handle->cb = cb;
memset(&handle->fo, 0, sizeof handle->fo);
handle->fo.fo_name = handle->filename;
uv__fs_event_rearm(handle);
ev_io_init(&handle->event_watcher, uv__fs_event_read, portfd, EV_READ);
ev_io_start(loop->ev, &handle->event_watcher);
ev_unref(loop->ev);
return 0;
}
开发者ID:0x00A,项目名称:uvxx,代码行数:32,代码来源:sunos.c
示例7: ioevent_init
int ioevent_init(IOEventPoller *ioevent, const int size,
const int timeout_ms, const int extra_events)
{
int bytes;
ioevent->size = size;
ioevent->extra_events = extra_events;
ioevent->iterator.index = 0;
ioevent->iterator.count = 0;
#if IOEVENT_USE_EPOLL
ioevent->poll_fd = epoll_create(ioevent->size);
bytes = sizeof(struct epoll_event) * size;
ioevent->events = (struct epoll_event *)malloc(bytes);
#elif IOEVENT_USE_KQUEUE
ioevent->poll_fd = kqueue();
bytes = sizeof(struct kevent) * size;
ioevent->events = (struct kevent *)malloc(bytes);
ioevent->care_events = 0;
#elif IOEVENT_USE_PORT
ioevent->poll_fd = port_create();
bytes = sizeof(port_event_t) * size;
ioevent->events = (port_event_t *)malloc(bytes);
#endif
if (ioevent->events == NULL) {
return errno != 0 ? errno : ENOMEM;
}
ioevent_set_timeout(ioevent, timeout_ms);
return 0;
}
开发者ID:ifzz,项目名称:libfastcommon,代码行数:32,代码来源:ioevent.c
示例8: ph_nbio_emitter_init
void ph_nbio_emitter_init(struct ph_nbio_emitter *emitter)
{
struct sigevent sev;
port_notify_t notify;
struct itimerspec ts;
emitter->io_fd = port_create();
if (emitter->io_fd == -1) {
ph_panic("port_create: `Pe%d", errno);
}
memset(&sev, 0, sizeof(sev));
memset(¬ify, 0, sizeof(notify));
memset(&ts, 0, sizeof(ts));
ts.it_interval.tv_nsec = WHEEL_INTERVAL_MS * 1000000;
ts.it_value.tv_nsec = ts.it_interval.tv_nsec;
notify.portnfy_port = emitter->io_fd;
sev.sigev_notify = SIGEV_PORT;
sev.sigev_value.sival_ptr = ¬ify;
if (timer_create(CLOCK_REALTIME, &sev, &emitter->port_timer)) {
ph_panic("failed to create timer: `Pe%d", errno);
}
if (timer_settime(emitter->port_timer, 0, &ts, NULL)) {
ph_panic("failed to set timer: `Pe%d", errno);
}
}
开发者ID:alemic,项目名称:libphenom,代码行数:29,代码来源:portfs.c
示例9: uv_fs_event_init
int uv_fs_event_init(uv_loop_t* loop,
uv_fs_event_t* handle,
const char* filename,
uv_fs_event_cb cb,
int flags) {
int portfd;
int first_run = 0;
if (loop->fs_fd == -1) {
if ((portfd = port_create()) == -1) {
uv__set_sys_error(loop, errno);
return -1;
}
loop->fs_fd = portfd;
first_run = 1;
}
uv__handle_init(loop, (uv_handle_t*)handle, UV_FS_EVENT);
uv__handle_start(handle); /* FIXME shouldn't start automatically */
handle->filename = strdup(filename);
handle->fd = PORT_UNUSED;
handle->cb = cb;
memset(&handle->fo, 0, sizeof handle->fo);
handle->fo.fo_name = handle->filename;
uv__fs_event_rearm(handle);
if (first_run) {
uv__io_init(&loop->fs_event_watcher, uv__fs_event_read, portfd);
uv__io_start(loop, &loop->fs_event_watcher, UV__POLLIN);
}
return 0;
}
开发者ID:2saki,项目名称:node,代码行数:34,代码来源:sunos.c
示例10: impl_pollcb_create
static apr_status_t impl_pollcb_create(apr_pollcb_t *pollcb,
apr_uint32_t size,
apr_pool_t *p,
apr_uint32_t flags)
{
pollcb->fd = port_create();
if (pollcb->fd < 0) {
return apr_get_netos_error();
}
{
int flags;
if ((flags = fcntl(pollcb->fd, F_GETFD)) == -1)
return errno;
flags |= FD_CLOEXEC;
if (fcntl(pollcb->fd, F_SETFD, flags) == -1)
return errno;
}
pollcb->pollset.port = apr_palloc(p, size * sizeof(port_event_t));
apr_pool_cleanup_register(p, pollcb, cb_cleanup, apr_pool_cleanup_null);
return APR_SUCCESS;
}
开发者ID:Ga-vin,项目名称:apache,代码行数:27,代码来源:port.c
示例11: evport_init
static void*
evport_init(struct event_base *base)
{
struct evport_data *evpd;
int i;
if (!(evpd = mm_calloc(1, sizeof(struct evport_data))))
return (NULL);
if ((evpd->ed_port = port_create()) == -1) {
mm_free(evpd);
return (NULL);
}
/*
* Initialize file descriptor structure
*/
evpd->ed_fds = mm_calloc(DEFAULT_NFDS, sizeof(struct fd_info));
if (evpd->ed_fds == NULL) {
close(evpd->ed_port);
mm_free(evpd);
return (NULL);
}
evpd->ed_nevents = DEFAULT_NFDS;
for (i = 0; i < EVENTS_PER_GETN; i++)
evpd->ed_pending[i] = -1;
evsig_init(base);
return (evpd);
}
开发者ID:boivie,项目名称:Libevent,代码行数:31,代码来源:evport.c
示例12: uv_fs_event_start
int uv_fs_event_start(uv_fs_event_t* handle,
uv_fs_event_cb cb,
const char* filename,
unsigned int flags) {
int portfd;
int first_run;
if (uv__is_active(handle))
return -EINVAL;
first_run = 0;
if (handle->loop->fs_fd == -1) {
portfd = port_create();
if (portfd == -1)
return -errno;
handle->loop->fs_fd = portfd;
first_run = 1;
}
uv__handle_start(handle);
handle->filename = strdup(filename);
handle->fd = PORT_UNUSED;
handle->cb = cb;
memset(&handle->fo, 0, sizeof handle->fo);
handle->fo.fo_name = handle->filename;
uv__fs_event_rearm(handle); /* FIXME(bnoordhuis) Check return code. */
if (first_run) {
uv__io_init(&handle->loop->fs_event_watcher, uv__fs_event_read, portfd);
uv__io_start(handle->loop, &handle->loop->fs_event_watcher, UV__POLLIN);
}
return 0;
}
开发者ID:0x20c24,项目名称:cjdns,代码行数:35,代码来源:sunos.c
示例13: port_check_reopen
/*
Reopen the port handle when our pid changes.
*/
static int port_check_reopen(struct port_event_context *port_ev)
{
struct tevent_fd *fde;
if (port_ev->pid == getpid()) {
return 0;
}
close(port_ev->port_fd);
port_ev->port_fd = port_create();
if (port_ev->port_fd == -1) {
tevent_debug(port_ev->ev, TEVENT_DEBUG_FATAL,
"port_create() failed");
return -1;
}
if (!ev_set_close_on_exec(port_ev->port_fd)) {
tevent_debug(port_ev->ev, TEVENT_DEBUG_WARNING,
"Failed to set close-on-exec, file descriptor may be leaked to children.\n");
}
port_ev->pid = getpid();
for (fde=port_ev->ev->fd_events;fde;fde=fde->next) {
fde->additional_flags &= PORT_ADDITIONAL_FD_FLAG_HAS_ASSOCIATION;
if (port_update_event(port_ev, fde) != 0) {
return -1;
}
}
return 0;
}
开发者ID:DanilKorotenko,项目名称:samba,代码行数:33,代码来源:tevent_port.c
示例14: ulimit
PortsEngine::PortsEngine()
{
int max = ulimit(4, 0);
if (max > 0)
{
MAX_DESCRIPTORS = max;
}
else
{
ServerInstance->Logs->Log("SOCKET", LOG_DEFAULT, "ERROR: Can't determine maximum number of open sockets!");
std::cout << "ERROR: Can't determine maximum number of open sockets!" << std::endl;
ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
}
EngineHandle = port_create();
if (EngineHandle == -1)
{
ServerInstance->Logs->Log("SOCKET", LOG_SPARSE, "ERROR: Could not initialize socket engine: %s", strerror(errno));
ServerInstance->Logs->Log("SOCKET", LOG_SPARSE, "ERROR: This is a fatal error, exiting now.");
std::cout << "ERROR: Could not initialize socket engine: " << strerror(errno) << std::endl;
std::cout << "ERROR: This is a fatal error, exiting now." << std::endl;
ServerInstance->Exit(EXIT_STATUS_SOCKETENGINE);
}
CurrentSetSize = 0;
ref = new EventHandler* [GetMaxFds()];
events = new port_event_t[GetMaxFds()];
memset(ref, 0, GetMaxFds() * sizeof(EventHandler*));
}
开发者ID:Paciik,项目名称:inspircd,代码行数:29,代码来源:socketengine_ports.cpp
示例15: wait_init
void
wait_init()
{
struct rlimit fd_new;
(void) getrlimit(RLIMIT_NOFILE, &init_fd_rlimit);
(void) getrlimit(RLIMIT_NOFILE, &fd_new);
fd_new.rlim_max = fd_new.rlim_cur = WAIT_FILES;
(void) setrlimit(RLIMIT_NOFILE, &fd_new);
if ((port_fd = port_create()) == -1)
uu_die("wait_init couldn't port_create");
wait_info_pool = uu_list_pool_create("wait_info", sizeof (wait_info_t),
offsetof(wait_info_t, wi_link), NULL, UU_LIST_POOL_DEBUG);
if (wait_info_pool == NULL)
uu_die("wait_init couldn't create wait_info_pool");
wait_info_list = uu_list_create(wait_info_pool, wait_info_list, 0);
if (wait_info_list == NULL)
uu_die("wait_init couldn't create wait_info_list");
(void) pthread_mutex_init(&wait_info_lock, &mutex_attrs);
}
开发者ID:AlfredArouna,项目名称:illumos-gate,代码行数:26,代码来源:wait.c
示例16: __libc_init_vfs
void __libc_init_vfs (void)
{
vfs_public_port = namer_find ("vfs", 1);
vfs_local_port = port_create (vfs_public_port,"vfs_public_port");
filename_area = area_create (0x1000, 0, (void **) &nameptr, 0);
__vfs_openconn (vfs_local_port, filename_area);
}
开发者ID:danilaslau,项目名称:frotznet,代码行数:8,代码来源:vfs.c
示例17: acpPollCreate
ACP_EXPORT acp_rc_t acpPollCreate(acp_poll_set_t *aPollSet,
acp_sint32_t aMaxCount)
{
acp_rc_t sRC;
ACP_POLL_CHECK_BEFORE_CREATE(aPollSet, aMaxCount);
/* Create port */
aPollSet->mHandle = port_create();
if (aPollSet->mHandle == -1)
{
return ACP_RC_GET_NET_ERROR();
}
else
{
/* do nothing */
}
sRC = acpMemCalloc((void **)&aPollSet->mObjs,
aMaxCount,
sizeof(acp_poll_obj_t));
if (ACP_RC_NOT_SUCCESS(sRC))
{
(void)close(aPollSet->mHandle);
return sRC;
}
else
{
/* do nothing */
}
sRC = acpMemCalloc((void **)&aPollSet->mEvents,
aMaxCount,
sizeof(port_event_t));
if (ACP_RC_NOT_SUCCESS(sRC))
{
(void)close(aPollSet->mHandle);
acpMemFree(aPollSet->mObjs);
return sRC;
}
else
{
/* do nothing */
}
aPollSet->mMaxCount = aMaxCount;
aPollSet->mCurCount = 0;
aPollSet->mEventHandle = -1;
aPollSet->mEventsNum = 0;
aPollSet->mCurrEvent = 0;
return ACP_RC_SUCCESS;
}
开发者ID:doong123,项目名称:altibase,代码行数:56,代码来源:acpPoll-PORT.c
示例18: calloc
static void *eventer_ports_spec_alloc(void) {
struct ports_spec *spec;
spec = calloc(1, sizeof(*spec));
spec->port_fd = port_create();
if(spec->port_fd < 0) {
mtevFatal(mtev_error, "error in eveter_ports_spec_alloc... spec->port_fd < 0 (%d)\n",
spec->port_fd);
}
return spec;
}
开发者ID:esproul,项目名称:libmtev,代码行数:10,代码来源:eventer_ports_impl.c
示例19: uv__platform_loop_init
int uv__platform_loop_init(uv_loop_t* loop, int default_loop) {
loop->fs_fd = -1;
loop->backend_fd = port_create();
if (loop->backend_fd == -1) return -1;
uv__cloexec(loop->backend_fd, 1);
return 0;
}
开发者ID:Andrepuel,项目名称:jxcore,代码行数:10,代码来源:sunos.c
示例20: user_port_create
port_id user_port_create(int32 queue_length, const char *uname)
{
dprintf("user_port_create: queue_length %d\n", queue_length);
if(uname != NULL) {
char name[SYS_MAX_OS_NAME_LEN];
int rc;
if(is_kernel_address(uname))
return ERR_VM_BAD_USER_MEMORY;
rc = user_strncpy(name, uname, SYS_MAX_OS_NAME_LEN-1);
if(rc < 0)
return rc;
name[SYS_MAX_OS_NAME_LEN-1] = 0;
return port_create(queue_length, name);
} else {
return port_create(queue_length, NULL);
}
}
开发者ID:HTshandou,项目名称:newos,代码行数:20,代码来源:port.c
注:本文中的port_create函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论