diff options
author | Mattias Andrée <maandree@kth.se> | 2016-08-19 17:42:38 +0200 |
---|---|---|
committer | Mattias Andrée <maandree@kth.se> | 2016-08-19 17:42:38 +0200 |
commit | 7c93406e58a4a4c8982c09c794b425833c44e345 (patch) | |
tree | 06c845bf95ea6408935f423192f62fa121f412cf | |
parent | ... (diff) | |
download | pylibcoopgamma-7c93406e58a4a4c8982c09c794b425833c44e345.tar.gz pylibcoopgamma-7c93406e58a4a4c8982c09c794b425833c44e345.tar.bz2 pylibcoopgamma-7c93406e58a4a4c8982c09c794b425833c44e345.tar.xz |
_send functions have async parameter rather than creating their instance
This is important for two reasons:
1) Otherwise, on failure such as EINTR, we don't have an instance
and we run into trouble.
2) This lets us reuse created instances
-rw-r--r-- | src/libcoopgamma.py | 43 |
1 files changed, 16 insertions, 27 deletions
diff --git a/src/libcoopgamma.py b/src/libcoopgamma.py index c09c59e..21843f6 100644 --- a/src/libcoopgamma.py +++ b/src/libcoopgamma.py @@ -906,19 +906,17 @@ class Context: ''' libcoopgamma_native.libcoopgamma_native_skip_message(self.address) - def get_crtcs_send(self): + def get_crtcs_send(self, async): ''' List all available CRTC:s, send request part - @return :AsyncContext Information about the request, that is needed to - identify and parse the response + @param async:AsyncContext Slot for information about the request that is + needed to identify and parse the response ''' - async = AsyncContext() + error = libcoopgamma_native.libcoopgamma_native_get_crtcs_send(self.address, async.address) if error != 0: - del async raise ErrorReport.create_error(error) - return async def get_crtcs_recv(self, async): ''' @@ -951,21 +949,18 @@ class Context: raise ErrorReport.create_error(ret) return ret - def get_gamma_info_send(self, crtc): + def get_gamma_info_send(self, crtc, async): ''' Retrieve information about a CRTC:s gamma ramps, send request part - @param crtc:str The name of the CRT - @return :AsyncContext Information about the request, that is needed to - identify and parse the response + @param crtc:str The name of the CRT + @param async:AsyncContext Slot for information about the request that is + needed to identify and parse the response ''' - async = AsyncContext() (successful, value) = libcoopgamma_native.libcoopgamma_native_get_gamma_info_send( crtc, self.address, async.address) if not successful: - del async raise ErrorReport.create_error(value) - return async def get_gamma_info_recv(self, async): ''' @@ -1002,21 +997,18 @@ class Context: raise ErrorReport.create_error(value) return CRTCInfo(*value) - def get_gamma_send(self, query): + def get_gamma_send(self, query, async): ''' Retrieve the current gamma ramp adjustments, send request part - @param query:FilterQuery The query to send - @return :AsyncContext Information about the request, that is + @param query:FilterQuery The query to send + @param async:AsyncContext Slot for information about the request that is needed to identify and parse the response ''' - async = AsyncContext() (successful, value) = libcoopgamma_native.libcoopgamma_native_get_gamma_send( query, self.address, async.address) if not successful: - del async raise ErrorReport.create_error(value) - return async def get_gamma_recv(self, async): ''' @@ -1053,21 +1045,18 @@ class Context: raise ErrorReport.create_error(value) return FilterTable(*value) - def set_gamma_send(self, filtr): + def set_gamma_send(self, filtr, async): ''' Apply, update, or remove a gamma ramp adjustment, send request part - @param filtr:Filter The filter to apply, update, or remove, gamma ramp - meta-data must match the CRTC's - @return :AsyncContext Information about the request, that is needed to - identify and parse the response + @param filtr:Filter The filter to apply, update, or remove, gamma ramp + meta-data must match the CRTC's + @param async:AsyncContext Slot for information about the request that is + needed to identify and parse the response ''' - async = AsyncContext() error = libcoopgamma_native.libcoopgamma_native_set_gamma_send(filtr, self.address, async.address) if error != 0: - del async raise ErrorReport.create_error(error) - return async def set_gamma_recv(self, async): ''' |