cps


License

License

GroupId

GroupId

com.treode
ArtifactId

ArtifactId

cps_2.9.2
Last Version

Last Version

0.1
Release Date

Release Date

Type

Type

jar
Description

Description

cps
cps
Project URL

Project URL

https://github.com/Treode/cps
Project Organization

Project Organization

com.treode
Source Code Management

Source Code Management

https://github.com/Treode/cps

Download cps_2.9.2

How to add to project

<!-- https://jarcasting.com/artifacts/com.treode/cps_2.9.2/ -->
<dependency>
    <groupId>com.treode</groupId>
    <artifactId>cps_2.9.2</artifactId>
    <version>0.1</version>
</dependency>
// https://jarcasting.com/artifacts/com.treode/cps_2.9.2/
implementation 'com.treode:cps_2.9.2:0.1'
// https://jarcasting.com/artifacts/com.treode/cps_2.9.2/
implementation ("com.treode:cps_2.9.2:0.1")
'com.treode:cps_2.9.2:jar:0.1'
<dependency org="com.treode" name="cps_2.9.2" rev="0.1">
  <artifact name="cps_2.9.2" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.treode', module='cps_2.9.2', version='0.1')
)
libraryDependencies += "com.treode" % "cps_2.9.2" % "0.1"
[com.treode/cps_2.9.2 "0.1"]

Dependencies

compile (1)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.9.2

test (2)

Group / Artifact Type Version
org.scalatest : scalatest_2.9.2 jar 2.0.M4
org.scalacheck : scalacheck_2.9.2 jar 1.9

Project Modules

There are no modules declared in this project.

CPS Wrappers for Java Asynchronous IO

The Treode CPS IO library wraps Java7's asynchronous sockets and files with Scala's continuations. You can write readable code without gnarly callbacks:

val address = new InetSocketAddress ("0.0.0.0", 4567)
val client = newSocket
client.connect (address)
val input = InputBuffer (client)
writeString (client, "Hello")
println (readString (input))

And let Scala's continuations plugin translate it to callbacks for you. The CPS library glues the continuations to the Java7 asynchronous methods. The CPS library also offers continuations style futures, locks and mailboxes. It provides a scheduler to connect the continuations tasks to any Java executor, including ForkJoinPool. An finally, it offers some tools to test applications, including a single threaded random scheduler, which deterministically simulates multithreaded scheduling; if it reveals a race condition, then it will do so repeatably so that you can debug it.

To use the library, and to include the testing stubs in your tests only, add the Treode OSS repository and add CPS as a dependency:

resolvers += Resolver.url (
  "treode-oss",
  new URL ("https://oss.treode.com/ivy")) (Resolver.ivyStylePatterns)

libraryDependencies += "com.treode" %% "cps" % "0.4.0" % "compile;test->scalatest"

You also need to setup SBT with the continuations plugin and activate it:

addCompilerPlugin ("org.scala-lang.plugins" % "continuations" % "2.9.3"),
scalacOptions ++= Seq ("-P:continuations:enable"),

Unfortunately, the CPS IO library cannot be used in Scala 2.10.x due to Bug 6817.

Browse the Scaladoc online.

Browse or subscribe to the online forum.

For working client and server applications, see the CPS IO Example.

com.treode

Treode

Versions

Version
0.1