Thread overview | |||||
---|---|---|---|---|---|
|
March 12, 2013 No monitor for immutable class instances? | ||||
---|---|---|---|---|
| ||||
Maybe a stupid question: an immutable class instance can't change, so is it possible and is it a good idea to remove (to not add) the monitor pointer field from immutable class instances, saving memory and allowing them to store one more word in the same amount of memory? Bye, bearophile |
March 12, 2013 Re: No monitor for immutable class instances? | ||||
---|---|---|---|---|
| ||||
Posted in reply to bearophile | On Mon, 11 Mar 2013 21:54:46 -0400, bearophile <bearophileHUGS@lycos.com> wrote:
> Maybe a stupid question: an immutable class instance can't change, so is it possible and is it a good idea to remove (to not add) the monitor pointer field from immutable class instances, saving memory and allowing them to store one more word in the same amount of memory?
Both immutable and mutable cast to const. A const function may be accessing mutable data in a read-only fashion, but it still may need to lock the monitor. Therefore, you must still be able to lock an immutable object.
-Steve
|
March 12, 2013 Re: No monitor for immutable class instances? | ||||
---|---|---|---|---|
| ||||
Posted in reply to Steven Schveighoffer | Steven Schveighoffer:
> Both immutable and mutable cast to const. A const function may be accessing mutable data in a read-only fashion, but it still may need to lock the monitor.
Right, no hope, thank you.
Bye,
bearophile
|
Copyright © 1999-2021 by the D Language Foundation