See also: much of the reason for implicit lambda.
/ Peter Bortas
Previous text:
2003-02-04 19:14: Subject: synchronized
One thing that's nice in Java is the 'synchronized keyword. It would be nice to have that functionality in Pike since it's easier than manually using mutex locks (nicer code):
synchronized void do_something() { ... }
and
mapping foo; void do_something() { synchronized(foo) { work on foo } }
and
void do_something() { ... synchronized { locked region } ... }
would be nice. The first one creates an implicit mutex lock for the entire method, the second one creates a lock bound to a specific variable (i.e you can have multiple methods "locking" the same variable) and the third method works just like the first, except for a specific region rather than the entire method.
Another possibility is to have synchronized classes:
synchronized class { ... }
and variable instanses:
synchronized mapping foo = ([]);
But the first three versions are IMHO more interesting.
How hard would this be to implement in pike? I'm guessing "quite hard", but... :)
/ David Hedbor