Package emma :: Module complement
[hide private]
[frames] | no frames]

Module complement

source code

The necessary class and decorators for interface and module


Copyright: (c) 2011 hackmeeting http://sindominio.net/hackmeeting

Author: Ruben Pollan

Organization: hackmeeting http://sindominio.net/hackmeeting

Contact: meskio@sindominio.net

License: This program is free software; you can redistribute it and/or modify it under the terms of the Do What The Fuck You Want To Public License, Version 2, as published by Sam Hocevar. See http://sam.zoy.org/projects/COPYING.WTFPL for more details.

Classes [hide private]
  Complement
Empty class mented to be inhered by interface and module
Functions [hide private]
 
use_lock(fn)
Decorator that adds a lock to a method
source code
Function Details [hide private]

use_lock(fn)

source code 

Decorator that adds a lock to a method

It decorates methods of child classes of Complement, usually interface or module. Adds the use of a locker (mutex) to the method, so the access to the class data is thread safe.

>>> from emma.complement import use_lock
>>> class myModule(Module):
...     @use_lock
...     def run(self):
...         self.var = 0
...     
...     @use_lock
...     def inc(self):
...         self.var += 1