socket :: PollFD :: defaultinit
socket :: PollFD :: from_poll_values
Create a PollFD object from NativePollFD informationssocket $ PollFD :: finalize_once
Real finalization method ofFinalizableOnce
, will be called only once
core :: Object :: class_factory
Implementation used byget_class
to create the specific class.
core :: Object :: defaultinit
socket :: PollFD :: defaultinit
core :: FinalizableOnce :: defaultinit
core :: Finalizable :: defaultinit
core :: Finalizable :: finalize
Liberate any resources held byself
before the memory holding self
is freed
core :: FinalizableOnce :: finalize_once
Real finalization method ofFinalizableOnce
, will be called only once
core :: FinalizableOnce :: finalized
Hasself
been finalized? (either by the GC or an explicit call to finalize
)
core :: FinalizableOnce :: finalized=
Hasself
been finalized? (either by the GC or an explicit call to finalize
)
socket :: PollFD :: from_poll_values
Create a PollFD object from NativePollFD informationscore :: Object :: is_same_instance
Return true ifself
and other
are the same instance (i.e. same identity).
core :: Object :: is_same_serialized
Isself
the same as other
in a serialization context?
core :: Object :: is_same_type
Return true ifself
and other
have the same dynamic type.
core :: Object :: output_class_name
Display class name on stdout (debug only).
# Wrapper for the data structure used for polling on a socket
class PollFD
super FinalizableOnce
# The PollFD object
private var poll_struct: NativeSocketPollFD
# A collection of the events to be watched
var events: Array[NativeSocketPollValues]
# Create a PollFD object from NativePollFD informations
init from_poll_values(pid: Int, events: Array[NativeSocketPollValues])
do
assert events.length >= 1
var events_in_one = events[0]
for i in [1 .. events.length - 1] do
events_in_one += events[i]
end
var poll_struct = new NativeSocketPollFD(pid, events_in_one)
init(poll_struct, events)
end
# Reads the response and returns an array with the type of events that have been found
private fun check_response(response: Int): Array[NativeSocketPollValues]
do
var resp_array = new Array[NativeSocketPollValues]
for i in events do
if c_check_resp(response, i) != 0 then
resp_array.push(i)
end
end
return resp_array
end
# Checks if the poll call has returned true for a particular type of event
private fun c_check_resp(response: Int, mask: NativeSocketPollValues): Int
`{
return response & mask;
`}
redef fun finalize_once
do
poll_struct.free
end
end
lib/socket/socket_c.nit:38,1--86,3