… | |
… | |
1060 | |
1060 | |
1061 | ///////////////////////////////////////////////////////////////////////////// |
1061 | ///////////////////////////////////////////////////////////////////////////// |
1062 | |
1062 | |
1063 | struct EventAPI *watcher_base::GEventAPI; |
1063 | struct EventAPI *watcher_base::GEventAPI; |
1064 | |
1064 | |
|
|
1065 | static void iw_dispatch (pe_event *ev) |
|
|
1066 | { |
|
|
1067 | iw *w = (iw *)ev->ext_data; |
|
|
1068 | w->call (*w); |
|
|
1069 | } |
|
|
1070 | |
|
|
1071 | void |
|
|
1072 | iw::alloc () |
|
|
1073 | { |
|
|
1074 | pe = GEventAPI->new_idle (0, 0); |
|
|
1075 | |
|
|
1076 | pe->base.callback = (void *)iw_dispatch; |
|
|
1077 | pe->base.ext_data = (void *)this; |
|
|
1078 | } |
|
|
1079 | |
1065 | static void iow_dispatch (pe_event *ev) |
1080 | static void iow_dispatch (pe_event *ev) |
1066 | { |
1081 | { |
1067 | iow *w = (iow *)ev->ext_data; |
1082 | iow *w = (iow *)ev->ext_data; |
1068 | w->call (*w, ((pe_ioevent *)ev)->got); |
1083 | w->call (*w, ((pe_ioevent *)ev)->got); |
1069 | } |
1084 | } |
… | |
… | |
1078 | |
1093 | |
1079 | pe->fd = -1; |
1094 | pe->fd = -1; |
1080 | pe->poll = 0; |
1095 | pe->poll = 0; |
1081 | } |
1096 | } |
1082 | |
1097 | |
1083 | iow & |
1098 | void |
1084 | iow::fd (int fd) |
1099 | iow::fd (int fd) |
1085 | { |
1100 | { |
1086 | pe->fd = fd; |
1101 | pe->fd = fd; |
1087 | |
|
|
1088 | return *this; |
|
|
1089 | } |
1102 | } |
1090 | |
1103 | |
1091 | int |
1104 | int |
1092 | iow::poll () |
1105 | iow::poll () |
1093 | { |
1106 | { |
1094 | return pe->poll; |
1107 | return pe->poll; |
1095 | } |
1108 | } |
1096 | |
1109 | |
1097 | iow & |
1110 | void |
1098 | iow::poll (int events) |
1111 | iow::poll (int events) |
1099 | { |
1112 | { |
1100 | if (pe->poll != events) |
1113 | if (pe->poll != events) |
1101 | { |
1114 | { |
1102 | if (pe->poll) stop (); |
1115 | if (pe->poll) stop (); |
1103 | pe->poll = events; |
1116 | pe->poll = events; |
1104 | if (pe->poll) start (); |
1117 | if (pe->poll) start (); |
1105 | } |
1118 | } |
1106 | |
|
|
1107 | return *this; |
|
|
1108 | } |
1119 | } |
1109 | |
1120 | |
1110 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1121 | MODULE = cf PACKAGE = cf PREFIX = cf_ |
1111 | |
1122 | |
1112 | BOOT: |
1123 | BOOT: |