Marthog / rust-stm

Software transactional memory
Apache License 2.0
249 stars 15 forks source link

Several refactor steps #4

Closed milibopp closed 8 years ago

milibopp commented 8 years ago

Not quite sure about the name of StmControlBlock now that I moved it. Generally, it looked like there were some encapsulation issues, so I went ahead to integrate it into the log.

Marthog commented 8 years ago

StmControlBlock was really ugly.

You replaced the two Options in LogVar with an enum and I think that changes the behavior when a Var is read and written.

Marthog commented 8 years ago

Jep,

        let x = var_ref.read();
        thread::sleep(Duration::from_millis(200));
        var_ref.write(x+10);

doesn't behave the way it should. I added another unit test to master branch.

milibopp commented 8 years ago

Oops, I was afraid something would break, when I did that, but it seemed like the logic could be transformed to be an enum. Let me redo this step.

Marthog commented 8 years ago

Three states read (with original value), write (with new value) and both, where read can be upgraged, are actually needed. I considered having independent optionals easier than dispatching on two possible types every time.

milibopp commented 8 years ago

Yes, I think it's safer to exclude the empty case at compile-time, when it is not needed.