📄 async.h
字号:
/*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Library General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
// async.h - Copyright (C) 2002, Simon Brenner
#ifndef __async_h__
#define __async_h__
#include <stdio.h>
#include <pthread.h>
#include <signal.h>
#include <errno.h>
#include <sys/types.h>
#include <unistd.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <vector>
#include <map>
class FdConnection;
template <typename _T>
class locker: public _T
{
pthread_mutex_t mutex[1];
public:
inline locker()
{
pthread_mutexattr_t attr={PTHREAD_MUTEX_ERRORCHECK_NP};
pthread_mutex_init(mutex, &attr);
}
inline ~locker()
{
if (pthread_mutex_destroy(mutex)==EBUSY)
{
Unlock();
pthread_mutex_destroy(mutex);
}
}
inline void Lock()
{
pthread_mutex_lock(mutex);
}
inline void Unlock()
{
pthread_mutex_unlock(mutex);
}
};
typedef unsigned int uint;
typedef u_int32_t uint32;
typedef u_int16_t uint16;
extern void AsyncNotifications(const std::vector <int> &, timeval *, bool noWrites=false);
extern void AsyncNotificationLoop(bool noWrites=false);
extern void InitAsync();
extern void CheckSocketError(FdConnection *);
extern void RemoveSocket(int, FdConnection *);
extern void AddSocket(int, FdConnection *);
extern bool LastSocketObject(int fd);
extern unsigned int GetAvailBytes(int fd);
#include <StreamConnection.hpp>
#include <DatagramConnection.hpp>
#endif // __async_h__
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -