All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.zink.scala.fly.example.WriteTake.scala Maven / Gradle / Ivy

Go to download

Fly Scala is a scala client library for working with a Fly Server. Fly is an object space server that is specifically written to provide lightweight object based messaging between computers running on a network. This distribution does not contain the server, please go to http://www.flyobjectspace.com/ for the server that matches the version of Fly Scala you want to use.

The newest version!
/*


Permission to use, copy, modify, and distribute this software for any 
purpose without fee is hereby granted, provided that this entire notice 
is included in all copies of any software which is or includes a copy 
or modification of this software and in all copies of the supporting 
documentation for such software.

THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

*/
package com.zink.scala.fly.example

import com.zink.scala.fly.Fly
import com.zink.scala.fly.kit._

object WriteTake extends App {

  val iterations = IntegerArgument(args, 1000)

  val space: Fly = FlyFinder.find() match {
    case Some(fly) => fly
    case None => {
      System.err.println("Failed to find a Fly Server running on the local network")
      throw new RuntimeException()
    }
  }

  // set up an object to write to the space
  val obj = new FlyEntry(name = "Fly 2", reference = BigInt(17))
  obj.setPayloadOfSize(100)

  // set up a tempate to match the above object
  val template = new FlyEntry(name = "Fly 2")
  template.reference = null // match any value in this template
  template.payload = null // ditto

  Timing("Processing " + iterations + " writes and takes", iterations) {
    space.write(obj, 1000)
    space.take(template, 0L)
  }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy