network.scheduler - Palamecia/mint GitHub Wiki
Module network.scheduler
Description
load network.scheduler
This module provides the Network.Scheduler class which manages synchronization between the network devices.
Packages
Enums
Network.Scheduler.PollEvent
This enum describe the events that can be watched on a specific channel.
| Constant | Value | Description |
|---|---|---|
| Accept | 0x0004 |
This event is set when a new connection is detected. |
| Close | 0x0010 |
This event is set when the connection is closed by the peer. |
| Error | 0x0008 |
This event is set when an error is detected. |
| Read | 0x0001 |
This event is set when the endpoint has some waiting data to read. |
| Write | 0x0002 |
This event is set when the data can be sent to the endpoint. |
Classes
Network.Scheduler
This class manages synchronization between the network devices.
Public members
| Modifiers | Member | Description |
|---|---|---|
class |
PollDescriptor | This class describe the polling state of a specific channel. |
enum |
PollEvent | This enum describe the events that can be watched on a specific channel. |
@ const |
instance | Returns the global instance of Network.Scheduler.Network.Scheduler. |
@ const |
poll | Waits until the activation of a requested event of a channel from fdset or un... |
const |
remove | Removes the channel from the scheduler. Returns true if channel is watched by... |
const |
run | Runs the synchronization loop synchronously. This loop calls Network.Schedule... |
const |
startSynchronizationLoop | Starts the synchronization loop in a separate thread. This loop calls Network... |
const |
stopSynchronizationLoop | Stops the synchronization loop thread. |
const |
synchronize | Waits until the activation of a requested event of a watched channel or until ``... |
const |
watch | Adds a channel to the scheduler. The channel object must provides the getSocket... |
Protected members
| Modifiers | Member | Description |
|---|---|---|
const |
synchronizationLoop | Runs the synchronization loop. This loop calls Network.Scheduler.synchronize ... |
Package members
| Modifiers | Member | Description |
|---|---|---|
const |
new | Internal constructor. |
Private members
| Modifiers | Member | Description |
|---|---|---|
final |
channels | Internal channels context. |
@ |
g_instance | Global object instance. |
@ |
g_lib | Global library handle. |
final |
loopRunning | Internal synchronization loop state. |
final |
mutex | Internal channel access mutex. |
final |
thread | Internal synchronization thead handle. |
Network.Scheduler.PollDescriptor
This class describe the polling state of a specific channel.
Public members
| Modifiers | Member | Description |
|---|---|---|
const |
getEvents | Returns the events activated on the channel as a mask of value from the Netwo... |
const |
getHandle | Returns the handle of the channel used by Network.Scheduler.PollDescriptor.Ne... |
const |
getRequestedEvents | Returns the events requested on the channel as a mask of value from the Netwo... |
const |
new | Creates a new context for the channel given by channel. The channel object mu... |
const |
poll | Waits until the activation of a requested event of the channel or until timeout... |
const |
setRequestedEvents | Sets requested events to events on the channel. The events parameter must be ... |
Private members
| Modifiers | Member | Description |
|---|---|---|
@ |
g_lib | Global library handle. |
final |
handle | Internal channel handle. |
Descriptions
Network.Scheduler.PollDescriptor.g_lib
lib ('libmint-network')
Global library handle.
Network.Scheduler.PollDescriptor.getEvents
def (const self)
Returns the events activated on the channel as a mask of value from the Network.Scheduler.PollEvent enum.
Only events passed to setRequestedEvents can be activated.
Network.Scheduler.PollDescriptor.getHandle
def (const self)
Returns the handle of the channel used by Network.Scheduler.
Network.Scheduler.PollDescriptor.getRequestedEvents
def (const self)
Returns the events requested on the channel as a mask of value from the Network.Scheduler.PollEvent enum.
Network.Scheduler.PollDescriptor.handle
null
Internal channel handle.
Network.Scheduler.PollDescriptor.new
def (self, channel)
Creates a new context for the channel given by channel. The
channel object must provide a getSocket method returning the
socket as a number.
Network.Scheduler.PollDescriptor.poll
def (self, timeout = 500)
Waits until the activation of a requested event of the channel or
until timeout milliseconds if no event become activated during
this period.
Returns true if an event was activated; otherwise returns false.
After a call to this method, the value returned by getEvents is updated.
Network.Scheduler.PollDescriptor.setRequestedEvents
def (self, events)
Sets requested events to events on the channel. The events
parameter must be a mask of values from the Network.Scheduler.PollEvent
enum.
Network.Scheduler.PollEvent.Accept
0x0004
This event is set when a new connection is detected.
Network.Scheduler.PollEvent.Close
0x0010
This event is set when the connection is closed by the peer.
Network.Scheduler.PollEvent.Error
0x0008
This event is set when an error is detected.
Network.Scheduler.PollEvent.Read
0x0001
This event is set when the endpoint has some waiting data to read.
Network.Scheduler.PollEvent.Write
0x0002
This event is set when the data can be sent to the endpoint.
Network.Scheduler.channels
{}
Internal channels context.
Network.Scheduler.g_instance
none
Global object instance.
Network.Scheduler.g_lib
lib ('libmint-network')
Global library handle.
Network.Scheduler.instance
def ()
Returns the global instance of Network.Scheduler.
Network.Scheduler.loopRunning
false
Internal synchronization loop state.
Network.Scheduler.mutex
null
Internal channel access mutex.
Network.Scheduler.new
def (self)
Internal constructor.
Network.Scheduler.poll
def (fdset, timeout)
Waits until the activation of a requested event of a channel from
fdset or until timeout milliseconds if no event become activated
during this period. The fdset parameter must be an array of
Network.Scheduler.PollDescriptor.
Returns true if an event was activated; otherwise returns false.
After a call to this method, the values returned by Network.Scheduler.PollDescriptor.getEvents are updated.
Network.Scheduler.remove
def (self, channel)
Removes the channel from the scheduler. Returns true if channel
is watched by the scheduler; otherwise returns false.
Network.Scheduler.run
def (self, timeout = 500)
Runs the synchronization loop synchronously. This loop calls
synchronize forever until no more channel is watched. The
timeout parameter is forwarded to the called method.
Network.Scheduler.startSynchronizationLoop
def (self, timeout = 500)
Starts the synchronization loop in a separate thread. This loop calls
synchronize forever until stopSynchronizationLoop is
called. The timeout parameter is forwarded to the called method.
Network.Scheduler.stopSynchronizationLoop
def (self)
Stops the synchronization loop thread.
Network.Scheduler.synchronizationLoop
def (self, timeout)
Runs the synchronization loop. This loop calls synchronize
forever until stopSynchronizationLoop is called. The timeout
parameter is forwarded to the called method.
Network.Scheduler.synchronize
def (self, timeout = 500)
Waits until the activation of a requested event of a watched channel
or until timeout milliseconds if no event become activated during
this period. The watched events on a channel are selected using the
Network.AsynchronousChannel.getEvents method. Any activated event
on a channel will then be notified to the channel using the
corresponding method:
Returns true if an event was activated; otherwise returns false.
After a call to this method, the values returned by Network.Scheduler.PollDescriptor.getEvents are updated.
Network.Scheduler.thread
null
Internal synchronization thead handle.
Network.Scheduler.watch
def (self, channel)
Adds a channel to the scheduler. The channel object must provides the
getSocket method. The same interface than Network.AsynchronousChannel
is also expected to automaticaly update the object on events. Returns
true if the channel is successfully watched; otherwise returns false.