Sese Framework
2.3.0
A cross-platform framework
Loading...
Searching...
No Matches
WSAEventLoop.h
Go to the documentation of this file.
1
// Copyright 2024 libsese
2
//
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
// you may not use this file except in compliance with the License.
5
// You may obtain a copy of the License at
6
//
7
// http://www.apache.org/licenses/LICENSE-2.0
8
//
9
// Unless required by applicable law or agreed to in writing, software
10
// distributed under the License is distributed on an "AS IS" BASIS,
11
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12
// See the License for the specific language governing permissions and
13
// limitations under the License.
14
21
#pragma once
22
23
#include <
sese/native/win/event/WSAEvent.h
>
24
#include <
sese/native/win/event/WSAEventConvert.h
>
25
#include <
sese/event/BaseEventLoop.h
>
26
27
#include <atomic>
28
29
#define MAX_EVENT_SIZE 64
30
31
namespace
sese::event
{
33
class
WSAEventLoop
:
public
BaseEventLoop
{
34
public
:
35
~WSAEventLoop
()
override
;
36
37
bool
init
()
override
;
38
39
void
dispatch
(uint32_t timeout)
override
;
40
41
void
onAccept
(
int
fd)
override
;
42
43
void
onRead
(
BaseEvent
*event)
override
;
44
45
void
onWrite
(
BaseEvent
*event)
override
;
46
47
void
onError
(
BaseEvent
*event)
override
;
48
49
void
onClose
(
BaseEvent
*event)
override
;
50
51
BaseEvent
*
createEvent
(
int
fd,
unsigned
int
events
,
void
*data)
override
;
52
53
void
freeEvent
(
BaseEvent
*event)
override
;
54
55
bool
setEvent
(
BaseEvent
*event)
override
;
56
57
void
setListenFd
(
int
fd)
override
;
58
59
protected
:
60
int
listenFd
{-1};
61
WSAEvent
*
listenEvent
{
nullptr
};
62
63
void
*
wsaEvent
{
nullptr
};
64
WSAEventConvert
convert
;
65
66
unsigned
long
numbers
= 0;
67
unsigned
long
long
sockets
[
MAX_EVENT_SIZE
]{};
68
void
*
wsaEvents
[
MAX_EVENT_SIZE
]{};
69
// Here, the lifecycle should be the responsibility of the user
70
WSAEvent
*
events
[
MAX_EVENT_SIZE
]{};
71
};
72
73
}
// namespace sese::event
74
75
#undef MAX_EVENT_SIZE
sese
native
win
event
WSAEventLoop.h
Generated on Tue Jan 7 2025 15:49:05 for Sese Framework by
1.11.0