1 // -*- mode:C++; tab-width:8; c-basic-offset:2; indent-tabs-mode:t -*-
2 // vim: ts=8 sw=2 smarttab
4 * Ceph - scalable distributed file system
6 * Copyright (C) 2015 XSky <haomai@xsky.com>
8 * Author: Haomai Wang <haomaiwang@gmail.com>
10 * This is free software; you can redistribute it and/or
11 * modify it under the terms of the GNU Lesser General Public
12 * License version 2.1, as published by the Free Software
13 * Foundation. See file COPYING.
17 #ifndef CEPH_COMMON_EVENT_SOCKET_H
18 #define CEPH_COMMON_EVENT_SOCKET_H
21 #if defined(__FreeBSD__) || defined(__APPLE__)
24 #include "include/event_type.h"
31 EventSocket(): socket(-1), type(EVENT_SOCKET_TYPE_NONE
) {}
32 bool is_valid() const { return socket
!= -1; }
33 int init(int fd
, int t
) {
35 case EVENT_SOCKET_TYPE_PIPE
:
37 case EVENT_SOCKET_TYPE_EVENTFD
:
50 case EVENT_SOCKET_TYPE_PIPE
:
54 ret
= write(socket
, buf
, 1);
62 case EVENT_SOCKET_TYPE_EVENTFD
:
65 ret
= write(socket
, &value
, sizeof (value
));