From 290ee8c03cfc67ab636794702e0d2ef4e054f26b Mon Sep 17 00:00:00 2001 From: Jon Pretty <jon.pretty@propensive.com> Date: Thu, 8 Feb 2024 15:05:36 +0100 Subject: [PATCH] Added incomplete getting-started text --- doc/basics.md | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/doc/basics.md b/doc/basics.md index ac70c91..b8d6149 100644 --- a/doc/basics.md +++ b/doc/basics.md @@ -1,2 +1,16 @@ -TBC +### Creating a new Mutex + +A new mutex, an instance of type `Mutex[ValueType]` for some choice of +`ValueTyp`, can be constructed by supplying its initial value to the `Mutex` +factory method, like so: +```scala +val count: Mutex[Int] = Mutex(32) +``` + +This represents a mutex variable, which is set to `32`. Any thread which has a +reference to `count` may read or modify this variable, but only in delimited +blocks. + +We can read the value only through a lambda applied to the `read` method of +`Mutex`, which provides a reference for accessing the value.