JavaClass.st
branchdevelopment
changeset 2968 d4963adcb114
parent 2966 afd174546057
child 2970 c9408352a572
--- a/JavaClass.st	Mon Dec 23 22:49:09 2013 +0100
+++ b/JavaClass.st	Mon Dec 23 22:59:16 2013 +0100
@@ -3058,6 +3058,69 @@
     "Modified: / 13-02-2013 / 09:36:44 / Jan Vrany <jan.vrany@fit.cvut.cz>"
 ! !
 
+!JavaClass methodsFor:'synchronized evaluation'!
+
+freeSynchronizationSemaphore
+    "free synchronizationSemaphore. May be used, to save memory when
+     an object is no longer used synchronized."
+
+    ^ self shouldNotImplement
+
+    "
+     self synchronized:[].
+     self synchronizationSemaphore.
+     self freeSynchronizationSemaphore.
+    "
+
+    "Created: / 28-01-1997 / 19:31:20 / stefan"
+    "Modified: / 08-12-2013 / 22:21:01 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+synchronizationSemaphore
+    "return the synchronization semaphore for myself.
+     subclasses may redefine"
+
+    ^ self shouldNotImplement
+
+    "
+      self synchronizationSemaphore
+    "
+
+    "Modified: / 28-01-1997 / 19:47:09 / stefan"
+    "Modified: / 08-12-2013 / 22:21:08 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+synchronizationSemaphore:aSemaphore
+    "set the synchronisationSemaphore for myself.
+     subclasses may redefine this method"
+
+    ^ self shouldNotImplement
+
+    "Modified: / 28-01-1997 / 19:37:48 / stefan"
+    "Modified: / 08-12-2013 / 22:21:19 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+!
+
+synchronized:aBlock
+    "Evaluate aBlock synchronized, i.e. use a monitor for this object"
+
+%{
+    extern void __monitorEnter(OBJ obj);
+    __monitorEnter(self);
+%}. 
+    aBlock ensure:[
+%{
+    extern void __monitorExit(OBJ obj);
+    __monitorExit(self);
+%}.
+    1. "/ To make stc happy (stc needs a return value but primitive code has none)
+    ].
+
+    "Created: / 28-01-1997 / 17:52:56 / stefan"
+    "Modified: / 30-01-1997 / 13:38:54 / cg"
+    "Modified: / 20-02-1997 / 09:43:35 / stefan"
+    "Modified: / 08-12-2013 / 22:27:03 / Jan Vrany <jan.vrany@fit.cvut.cz>"
+! !
+
 !JavaClass methodsFor:'unwind'!
 
 unwindHandlerInContext: aContext