- Add documentation for classes:
- (C++) PythonPolicyManager - (Python) Policy, ScriptAdapter, fcfs git-svn-id: svn://svn.gna.org/svn/sgpemv2/trunk@408 3ecf2c5c-341e-0410-92b4-d18e462d057c
This commit is contained in:
parent
9091035003
commit
e2211907f5
4 changed files with 188 additions and 34 deletions
|
@ -1,9 +1,10 @@
|
|||
import mutex, thread
|
||||
import sgpem
|
||||
|
||||
## Var Global syncronization object
|
||||
_g_mutex = mutex.mutex()
|
||||
|
||||
## @val Synchronized return value you can read from C++
|
||||
## @var Synchronized return value you can read from C++
|
||||
# when a threaded function returns
|
||||
_ret_val = None
|
||||
|
||||
|
@ -15,18 +16,32 @@ _ret_val = None
|
|||
# the policy member functions on a different thread, so
|
||||
# to ensure asyncronous control.
|
||||
#
|
||||
# Instantiated in the C++ code, it should be instantiated like:
|
||||
# Instantiated in the C++ code, it is created like:
|
||||
# @code
|
||||
# adapter = ScriptAdapter(UserPolicyClass)
|
||||
# @endcode
|
||||
#
|
||||
# The user shouldn't care about this class at all.
|
||||
class ScriptAdapter :
|
||||
## @var The policy this ScriptAdapter will use for calls
|
||||
_policy = None
|
||||
|
||||
## @var The event to pass to Policy.sort_queue() after the asynchronous call
|
||||
_event = None
|
||||
|
||||
|
||||
|
||||
## @brief Constructor of ScriptAdapter
|
||||
#
|
||||
# @param self The caller object
|
||||
# @param policy A user-implemented class inheriting from Policy.Policy
|
||||
def __init__(self, policy):
|
||||
self._policy = policy()
|
||||
print 'ScriptAdapter for policy ', policy, ' loaded'
|
||||
|
||||
|
||||
## @brief Asynchronously call Policy.configure()
|
||||
#
|
||||
# @param self The caller object
|
||||
def async_configure(self):
|
||||
_g_mutex.lock(ScriptAdapter._wrap_configure, self )
|
||||
|
||||
|
@ -37,7 +52,15 @@ class ScriptAdapter :
|
|||
# call configure method
|
||||
self._policy.configure()
|
||||
_g_mutex.unlock()
|
||||
|
||||
|
||||
|
||||
## @brief Asynchronously call Policy.sort_queue()
|
||||
#
|
||||
# The queue is asked directly to the C++ sgpem::Scheduler
|
||||
# singleton, via SWIG
|
||||
#
|
||||
# @param self The caller object
|
||||
# @param event The event to pass to sort_queue
|
||||
def async_sort_queue(self, event):
|
||||
self._event = event
|
||||
_g_mutex.lock(ScriptAdapter._wrap_sort_queue, self)
|
||||
|
@ -52,6 +75,10 @@ class ScriptAdapter :
|
|||
self._policy.sort_queue(event, queue)
|
||||
_g_mutex.unlock()
|
||||
|
||||
|
||||
## @brief Asynchronously call Policy.is_preemptive()
|
||||
#
|
||||
# @param self The caller object
|
||||
def async_is_preemptive(self):
|
||||
_g_mutex.lock(ScriptAdapter._wrap_is_preemptive, self)
|
||||
|
||||
|
@ -61,7 +88,11 @@ class ScriptAdapter :
|
|||
def _wrap_is_preemptive_callback(self):
|
||||
_ret_val = self._policy.is_preemptive()
|
||||
_g_mutex.unlock()
|
||||
|
||||
|
||||
## @brief Asynchronously call Policy.get_time_slice()
|
||||
#
|
||||
# @param self The caller object
|
||||
def async_get_time_slice(self):
|
||||
_g_mutex.lock(ScriptAdapter._wrap_get_time_slice, self)
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue