Skip to content

Commit d84605c

Browse files
committed
more documentation
1 parent 87413ff commit d84605c

File tree

4 files changed

+19
-21
lines changed

4 files changed

+19
-21
lines changed

shared/src/main/scala/gopher/Select.scala

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -107,14 +107,6 @@ class Select[F[_]](api: Gopher[F]):
107107
transparent inline def aforever(inline pf: PartialFunction[Any,Unit]): F[Unit] =
108108
${ SelectMacro.aforeverImpl('pf, 'api) }
109109

110-
/*
111-
transparent inline def aforever_async(inline pf: PartialFunction[Any,F[Unit]]): F[Unit] =
112-
given CpsSchedulingMonad[F] = api.asyncMonad
113-
async(using api.asyncMonad).apply {
114-
val runner = new SelectForever[F](api)
115-
runner.applyAsync(pf)
116-
}
117-
*/
118110

119111

120112

shared/src/main/scala/gopher/SelectForever.scala

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ import scala.concurrent.duration._
77

88

99
/**
10-
* forever Apply
10+
* Result of `select.forever`: apply method accept partial pseudofunction which evalueated forever.
1111
**/
1212
class SelectForever[F[_]](api: Gopher[F]) extends SelectGroupBuilder[F,Unit, Unit](api):
1313

@@ -17,10 +17,6 @@ class SelectForever[F[_]](api: Gopher[F]) extends SelectGroupBuilder[F,Unit, Uni
1717
SelectMacro.foreverImpl('pf,'api)
1818
}
1919

20-
transparent inline def applyAsync(inline pf: PartialFunction[Any,Unit]): F[Unit] =
21-
${
22-
SelectMacro.aforeverImpl('pf, 'api)
23-
}
2420

2521
def runAsync(): F[Unit] =
2622
given CpsSchedulingMonad[F] = api.asyncMonad

shared/src/main/scala/gopher/SelectGroup.scala

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,18 @@ import java.util.logging.{Level => LogLevel}
1414

1515

1616
/**
17-
* Select group is a virtual 'lock' object, where only
18-
* ne fro rieader and writer can exists at the sae time.
17+
* Select group is a virtual 'lock' object.
18+
* Readers and writers are grouped into select groups. When
19+
* event about avaiability to read or to write is arrived and
20+
* no current event group members is running, than run of one of the members
21+
* is triggered.
22+
* I.e. only one from group can run.
23+
*
24+
* Note, that application develeper usually not work with `SelectGroup` directly,
25+
* it is created internally by `select` pseudostatement.
26+
*
27+
*@see [gopher.Select]
28+
*@see [gopher.select]
1929
**/
2030
class SelectGroup[F[_], S](api: Gopher[F]) extends SelectListeners[F,S,S]:
2131

@@ -28,10 +38,10 @@ class SelectGroup[F[_], S](api: Gopher[F]) extends SelectListeners[F,S,S]:
2838
* 2 - expired
2939
**/
3040
val waitState: AtomicInteger = new AtomicInteger(0)
31-
var call: Try[S] => Unit = { _ => () }
41+
private var call: Try[S] => Unit = { _ => () }
3242
private inline def m = api.asyncMonad
33-
val retval = m.adoptCallbackStyle[S](f => call=f)
34-
val startTime = new AtomicLong(0L)
43+
private val retval = m.adoptCallbackStyle[S](f => call=f)
44+
private val startTime = new AtomicLong(0L)
3545
var timeoutScheduled: Option[Time.Scheduled] = None
3646

3747
override def asyncMonad = api.asyncMonad

shared/src/main/scala/gopher/SelectMacro.scala

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ object SelectMacro:
3838
'{ $base.onRead($ch.done)($f) }
3939

4040

41-
def selectListenerBuilder1[F[_]:Type, S:Type, R:Type, L <: SelectListeners[F,S,R]:Type](
41+
def selectListenerBuilder[F[_]:Type, S:Type, R:Type, L <: SelectListeners[F,S,R]:Type](
4242
constructor: Expr[L],
4343
caseDefs: List[SelectorCaseExpr[F,S,R]])(using Quotes): Expr[L] =
4444
val s0 = constructor
@@ -51,7 +51,7 @@ object SelectMacro:
5151
constructor: Expr[L],
5252
caseDefs: List[SelectorCaseExpr[F,S,R]],
5353
api:Expr[Gopher[F]])(using Quotes): Expr[R] =
54-
val g = selectListenerBuilder1(constructor, caseDefs)
54+
val g = selectListenerBuilder(constructor, caseDefs)
5555
// dotty bug if g.run
5656
val r = '{ await($g.runAsync())(using ${api}.asyncMonad) }
5757
r.asExprOf[R]
@@ -60,7 +60,7 @@ object SelectMacro:
6060
constructor: Expr[L],
6161
caseDefs: List[SelectorCaseExpr[F,S,R]],
6262
api:Expr[Gopher[F]])(using Quotes): Expr[F[R]] =
63-
val g = selectListenerBuilder1(constructor, caseDefs)
63+
val g = selectListenerBuilder(constructor, caseDefs)
6464
// dotty bug if g.run
6565
val r = '{ $g.runAsync() }
6666
r.asExprOf[F[R]]

0 commit comments

Comments
 (0)