diff options
| author | mo khan <mo@mokhan.ca> | 2013-08-28 07:20:13 -0600 |
|---|---|---|
| committer | mo khan <mo@mokhan.ca> | 2013-08-28 07:20:13 -0600 |
| commit | db1191ec0e7305d684383f8974e2fa437f77ad5a (patch) | |
| tree | 5e27b197dff849d22d8e1f50eb75aa499b16bd06 /code/snippets/cow_no_writes.rb | |
Diffstat (limited to 'code/snippets/cow_no_writes.rb')
| -rw-r--r-- | code/snippets/cow_no_writes.rb | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/code/snippets/cow_no_writes.rb b/code/snippets/cow_no_writes.rb new file mode 100644 index 0000000..6e93ff7 --- /dev/null +++ b/code/snippets/cow_no_writes.rb @@ -0,0 +1,10 @@ +arr = [1,2,3] + +fork do + # At this point the child process has been initialized. + # Using CoW this process doesn't need to copy the arr variable, + # since it hasn't modified any shared values it can continue reading + # from the same memory location as the parent process. + p arr +end + |
