I
Iñaki Baz Castillo
Hi, i'm using Ragel parser generating Ruby code. The generated code
uses a Class instead of an instance, and that class has lots of
attributes and methods. Something like:
--------------
class MyParser
class << self
attr_accessor :_machine_trans_keys
private :_machine_trans_keys, :_machine_trans_keys=3D
end
self._machine_trans_keys =3D [
0, 0, 9, 34, 10, 10,
9, 32, 9, 34, -64,
126, -128, -65, -128, -65,
-128, -65, -128, -65, -128, -65,
10, 10, 9, 32, 13,
13, 10, 10, 0, 127,
0, 0, 0
]
...
...
def self.run_machine(data)
...
end
end
-------------
So I wonder how could I use this class into a threaded program. AFAIK
a singleton class is the Class itself, so if a running thread modifies
some singleton attribute then all the other threads will see that
change (error!!!).
Am I right? How could I achieve it?
Thanks a lot.
--=20
I=C3=B1aki Baz Castillo
<[email protected]>
uses a Class instead of an instance, and that class has lots of
attributes and methods. Something like:
--------------
class MyParser
class << self
attr_accessor :_machine_trans_keys
private :_machine_trans_keys, :_machine_trans_keys=3D
end
self._machine_trans_keys =3D [
0, 0, 9, 34, 10, 10,
9, 32, 9, 34, -64,
126, -128, -65, -128, -65,
-128, -65, -128, -65, -128, -65,
10, 10, 9, 32, 13,
13, 10, 10, 0, 127,
0, 0, 0
]
...
...
def self.run_machine(data)
...
end
end
-------------
So I wonder how could I use this class into a threaded program. AFAIK
a singleton class is the Class itself, so if a running thread modifies
some singleton attribute then all the other threads will see that
change (error!!!).
Am I right? How could I achieve it?
Thanks a lot.
--=20
I=C3=B1aki Baz Castillo
<[email protected]>