Add sub-controls for Hack array compat runtime checks
[hiphop-php.git] / hphp / runtime / base / file-await.h
blob4f5908a42c2ca5b6a5f4efc2892540f26ee56d23
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"
8 namespace HPHP {
9 /////////////////////////////////////////////////////////////////////////////
11 struct FileAwait;
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;
21 private:
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;
33 private:
34 FileAwait* m_fileAwait;
37 struct FileAwait : AsioExternalThreadEvent {
38 enum Status {
39 ERROR = -1,
40 TIMEOUT = 0,
41 READY,
42 CLOSED,
45 FileAwait(int fd, uint16_t events, double timeout);
46 ~FileAwait();
47 void unserialize(Cell& c) override;
48 void setFinished(int64_t status);
49 private:
50 std::shared_ptr<FileEventHandler> m_file;
51 std::shared_ptr<FileTimeoutHandler> m_timeout;
52 int m_result{-1};
53 bool m_finished{false};
56 /////////////////////////////////////////////////////////////////////////////
57 } // namespace HPHP
58 #endif // incl_HPHP_FILE_AWAIT_H