core.shared_data | index

`# Copyright 2011 the original author or authors.
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.`

Classes

``

__builtin__.object
  SharedData
  SharedHash
  SharedSet

class SharedData(__builtin__.object)

``

`Sometimes it is desirable to share immutable data between different event loops, for example to implement a
cache of data.
This class allows instances of shareddata data structures to be looked up and used from different event loops.
The data structures themselves will only allow certain data types to be stored into them. This shields the
user from worrying about any thread safety issues might occur if mutable objects were shareddata between event loops.
The following types can be stored in a shareddata data structure:
String
FixNum
Float
Buffer - this will be automatically copied, and the copy will be stored in the structure.
`

Static methods defined here:

check_obj(obj)
  `Convert to corresponding Java objects
  and make copies where appropriate (the underlying java map will also make copies for some data types too)`

get_hash(key)
  `Return a Hash with the specific name. All invocations of this method with the same value of name
  are guaranteed to return the same Hash instance.
  Keyword arguments:
  @param key: Get the hash with the key.
  @return: the hash.`

get_set(key)
  `Return a Set with the specific name. All invocations of this method with the same value of name
  are guaranteed to return the same Set instance.
  Keyword arguments:
  @param key: Get the set with the key.
  @return: the shared set.`

remove_hash(key)
  `Remove the hash
  Keyword arguments:
  @param key: The key of the hash.`

remove_set(key)
  `Remove the set
  Keyword arguments:
  @param key: The key of the set.`

shared_data()

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

class SharedHash(__builtin__.object)

``

Methods defined here:

__eq__(self, other)

__getitem__(self, key)

__init__(self, hash)

__setitem__(self, key, val)

__str__(self)

items(self)

iteritems(self)

keys(self)

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

class SharedSet(__builtin__.object)

``

Methods defined here:

__eq__(self, other)

__init__(self, java_set)

__iter__(self)

__len__(self)

__str__(self)

add(self, obj)
  `Add an object to the set
  Keyword arguments:
  @param obj: The object to add
  @return: self`

clear(self)
  `Clear the set`

delete(self, obj)
  `Delete an object from the set
  Keyword arguments:
  @param obj: the object to delete`

each(self, func)
  `Call the func for every element of the set
  Keyword arguments:
  @param func: The function to call.`

empty(self)
  `returns True if the set is empty`

include(self, obj)
  `Does the set contain an element?
  Keyword arguments:
  @param obj: the object to check if the set contains
  @return: True if the object is contained in the set`

size(self)
  `returns the number of elements in the set`

Data descriptors defined here:

__dict__
  `dictionary for instance variables (if defined)`

__weakref__
  `list of weak references to the object (if defined)`

Data
`` |  | __author__ = 'Scott Horn' __credits__ = 'Based entirely on work by Tim Fox http://tfox.org' __email__ = 'scott@hornmicro.com' org = <java package org 0x2>

Author
`` |  | Scott Horn

Credits
`` |  | Based entirely on work by Tim Fox http://tfox.org