1 #ifndef incl_HPHP_FILE_AWAIT_H
2 #define incl_HPHP_FILE_AWAIT_H
4 #include "hphp/runtime/ext/extension.h"
5 #include "hphp/runtime/ext/asio/asio-external-thread-event.h"
6 #include "hphp/runtime/ext/asio/socket-event.h"
9 /////////////////////////////////////////////////////////////////////////////
13 struct FileTimeoutHandler
: AsioTimeoutHandler
{
14 friend struct FileAwait
;
16 FileTimeoutHandler(AsioEventBase
* base
, FileAwait
* fa
):
17 AsioTimeoutHandler(base
), m_fileAwait(fa
) {}
19 void timeoutExpired() noexcept override
;
22 FileAwait
* m_fileAwait
;
25 struct FileEventHandler
: AsioEventHandler
{
26 friend struct FileAwait
;
28 FileEventHandler(AsioEventBase
* base
, int fd
, FileAwait
* fa
):
29 AsioEventHandler(base
, fd
), m_fileAwait(fa
) {}
31 void handlerReady(uint16_t events
) noexcept override
;
34 FileAwait
* m_fileAwait
;
37 struct FileAwait
: AsioExternalThreadEvent
{
45 FileAwait(int fd
, uint16_t events
, double timeout
);
47 void unserialize(Cell
& c
) override
;
48 void setFinished(int64_t status
);
50 std::shared_ptr
<FileEventHandler
> m_file
;
51 std::shared_ptr
<FileTimeoutHandler
> m_timeout
;
53 bool m_finished
{false};
56 /////////////////////////////////////////////////////////////////////////////
58 #endif // incl_HPHP_FILE_AWAIT_H