Skip to content

Commit

Permalink
ByteString offheap patch (#7)
Browse files Browse the repository at this point in the history
  • Loading branch information
Karasiq authored Jul 21, 2020
1 parent a75d936 commit 1245f6b
Showing 6 changed files with 1,946 additions and 13 deletions.
10 changes: 9 additions & 1 deletion build.sbt
Original file line number Diff line number Diff line change
@@ -416,6 +416,7 @@ lazy val javafx = (project in file("javafx"))
.dependsOn(core)

lazy val desktopApp = (project in file("desktop-app"))
.dependsOn(`larray-bytestring`, coreAssembly, server, javafx, `drive-fuse`)
.settings(
commonSettings,
packageSettings,
@@ -427,7 +428,6 @@ lazy val desktopApp = (project in file("desktop-app"))
else Nil),
fork in run := true
)
.dependsOn(coreAssembly, server, javafx, `drive-fuse`)
.enablePlugins(JavaAppPackaging, ClasspathJarPlugin, JDKPackagerPlugin)

// -----------------------------------------------------------------------
@@ -485,3 +485,11 @@ lazy val shadowcloud = (project in file("."))
)
//.enablePlugins(com.github.sbtliquibase.SbtLiquibase)
.aggregate(coreAssembly, `server-api-routes`)


lazy val `larray-bytestring` = project
.settings(
commonSettings,
name := "larray-bytestring",
libraryDependencies ++= ProjectDeps.larray
)
Original file line number Diff line number Diff line change
@@ -23,7 +23,9 @@ object SCDesktopMain extends App {
implicit val actorSystem = ActorSystem("shadowcloud", config)

val sc = ShadowCloud(actorSystem)

import sc.implicits.executionContext

sc.init()

val httpServer = SCAkkaHttpServer(sc)
17 changes: 17 additions & 0 deletions larray-bytestring/src/main/scala/akka/util/BSLArray.scala
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
package akka.util

import xerial.larray.{LArray, LByteArray}

object BSLArray {
def toLArray(arr: Array[Byte]): LByteArray = {
val lb = new LByteArray(arr.length)
for (i <- arr.indices) lb(i) = arr(i)
lb
}

def toHeapArray(lb: LArray[Byte]): Array[Byte] = {
val heapArr = new Array[Byte](lb.length.ensuring(_.isValidInt).toInt)
for (i <- heapArr.indices) heapArr(i) = lb(i)
heapArr
}
}
Loading

0 comments on commit 1245f6b

Please sign in to comment.