logo
down
shadow

Pure not a member of objective Promise in PlayFramework


Pure not a member of objective Promise in PlayFramework

By : Vasilescu Ionut Vale
Date : November 21 2020, 01:01 AM
I wish did fix the issue. That's using a much older version of the Play libraries. Promise.pure was deprecated in 2.2.x, and removed in 2.3.x. You can use scala.concurrent.Future.successful instead.
code :
Future.successful( ( Iteratee.ignore[JsValue], enumerator ) )


Share : facebook icon twitter icon
error C2248: 'std::promise<_Ty>::promise' : cannot access private member declared in class 'std::promise<_Ty>

error C2248: 'std::promise<_Ty>::promise' : cannot access private member declared in class 'std::promise<_Ty>


By : user3232727
Date : March 29 2020, 07:55 AM
I wish this helpful for you Your code compiles successfully on both gcc and clang (once the missing header is included). It fails on MSVC because of this line
code :
chunks_m.emplace_back(std::move(new_lower_chunk));
chunk_to_sort() = default;

chunk_to_sort(chunk_to_sort&& other)
: data_m(std::move(other.data_m))
, promise_m(std::move(other.promise_m))
{}
What is the correct way to call the pure virtual member when another member exists with another signature?

What is the correct way to call the pure virtual member when another member exists with another signature?


By : user3745853
Date : March 29 2020, 07:55 AM
I hope this helps you . Bring the base class declaration into derived class scope with a using-declaration:
code :
class MyClass : public IInterface
{
public:
    using IInterface::func;
    void func(int i) { func(); }
};
void func(int i) { static_cast<IInterface*>(this)->func(); }
Compose multiple promises into one promise PlayFramework 2.4

Compose multiple promises into one promise PlayFramework 2.4


By : user3850391
Date : March 29 2020, 07:55 AM
Any of those help waitAll has been replaced with F.Promise.sequence.
From the docs
code :
package controllers;

import java.util.HashMap;
import java.util.Map;
import play.libs.F;
import play.libs.Json;
import play.libs.ws.WS;
import play.libs.ws.WSResponse;
import play.mvc.Controller;
import play.mvc.Result;
import play.mvc.Results;

public class Application extends Controller {

    public F.Promise<Result> index() {
        final long start = System.currentTimeMillis();
        final F.Function<WSResponse,Long> timing = response -> System.currentTimeMillis() - start;

        return F.Promise.sequence(WS.url("http://www.google.com").get().map(timing),
                                  WS.url("http://www.yahoo.com").get().map(timing),
                                  WS.url("http://www.bing.com").get().map(timing))
                        .map(list -> {
                            Map<String, Long> data = new HashMap<>();
                            data.put("google", list.get(0));
                            data.put("yahoo", list.get(1));
                            data.put("bing", list.get(2));
                            return data;
                        })
                        .map(Json::toJson)
                        .map(Results::ok);
    }

}
How to convert Observable to Promise in playframework java api

How to convert Observable to Promise in playframework java api


By : Maaz Baig
Date : March 29 2020, 07:55 AM
this will help Seems like i found solution.
Function to wrap observable with promise:
code :
   public static <T> F.Promise<T> observableToPromise(Observable<T> obs) {
      scala.concurrent.Promise<T> scalaPromise = scala.concurrent.Promise$.MODULE$.<T>apply();
      obs.subscribe(
          result -> scalaPromise.success(result),
          throwable -> scalaPromise.failure(throwable)
      );
      return F.Promise.wrap(scalaPromise.future());
   }
   public F.Promise<Result> index() {
      //convert observable to promise then map computation result to F.Promise<Result>
      F.Promise<Result> succeedPromise =
          observableToPromise(
              //computation on another thread
              intensiveComputationObservable().subscribeOn(Schedulers.newThread())
          ).map(result -> ok(String.valueOf(result)));

      //if exception while computation thrown, we returns another status
      return succeedPromise
          .recoverWith(throwable -> F.Promise.pure(internalServerError("error")));
   }
How to initialize member in abstract class with std::function in which pure virtual member is called?

How to initialize member in abstract class with std::function in which pure virtual member is called?


By : Aneeshia
Date : March 29 2020, 07:55 AM
To fix the issue you can do The problem here is order of destructors calls. Here is a simple example:
code :
#include <functional>
#include <iostream>
#include <memory>
#include <string>
using namespace std;

class Object {
 public:
  Object(){ cout<<"O\n"; }
 ~Object() { cout<<"~O\n"; }
};

class AbstractBase {
 public:
  AbstractBase(){ cout<<"A\n"; }
 ~AbstractBase() { cout<<"~A\n"; }

 private:
  Object object;
};

class Derived1 : public AbstractBase {
 public:
 Derived1() : AbstractBase()
 { cout<<"1\n"; }
 ~Derived1() { cout<<"~1\n"; }
};

class Derived2 : public AbstractBase {
 public:
 Derived2() : AbstractBase()
 { cout<<"2\n"; }
 ~Derived2() { cout<<"~2\n"; }
};

int main() {
    Derived1 d1;
    Derived2 d2;

    return 0;
}
O
A
1
O
A
2
~2
~A
~O
~1
~A
~O
Related Posts Related Posts :
  • What is the usage of a final var in Scala
  • Define Generic Types with String
  • Why there is a ClassCastException when isInstanceOf returns true on a scala type with wildcard parameter?
  • How to reaload scala application after code change using actors and sbt
  • akka non-blocking BoundedMailbox
  • Why are constructor parameters made into members for case classes?
  • Higher order tail recursive function needs to terminate early
  • How can I reusably filter based on type in Scala?
  • Why does Scala sbt update every time I start it from command prompt?
  • Recommended Scala io library
  • Thread-safely transforming a value in a mutable map
  • Why does chaining match expressions does not compile?
  • Ebean not persisting foreign keys
  • Difference between def m(p: T forSome {type T} and def m1(p:Any), is there any ? Explanation needed based on Scala Langu
  • macro does not find out enclosing vals
  • Spark : how to run spark file from spark shell
  • Flattening a list of lists to a set with exceptions in scala
  • flatMap implementation in Scala
  • Confused about a few lines code in a scala official document page
  • How to input parameters when running bash command with Scala
  • Location header is lost if max-redirects > 1
  • Controller Spec is using FakeApplication, but can't load test configuration
  • Scala code analyzer targets case variable names that are identical to the outer matched varables - "suspicous shado
  • Why does authorize directive execute after the code it's supposed to protect?
  • Scala. Checking if a Type is Comparable
  • Does having a private constructor on a value class negate the benefits of a value class?
  • How to transform submitted json in Play 2.0?
  • Scala warning match may not be exhaustive
  • How to unmarshal POST params and JSON body in a single route?
  • Spark:How to use join method?
  • is client thread-safe in Twitter Finagle
  • Why is the method accepts only one argument?
  • Scala Play 2.3 Working with gCloud Storage - any libs to go async?
  • spray.io strange get/delete/detach directives behavior
  • SBT cannot resolve class declared in src/main/scala in a src/test/scala test class
  • Scala typeclass without function argument
  • Configuring actor behavior using typesafe Config and HOCON
  • Scalatra: Migrating Jersey Filters to Scalatra
  • Compilation error when using Scaldi
  • Scalac hanging in phase typer
  • how to have different source code when cross-compiling Scala with sbt? (changes in MurmurHash)
  • How to set different scalacOptions per Scala version when cross-compiling using Build.scala?
  • Possible Bug in JDBC?
  • Is there a Scala compiler flag to warn when tail recursion is applied without annotation?
  • scala case class put methods in companion object?
  • multiproject sbt doesn't generate file structure
  • Scala "multilevel" abstract class / abstract objects replacement
  • Scala, getting the type parameters of a KList as an HList
  • Why does Play refuse form reporting "Cannot resolve method apply with such signature: Missing arguments"?
  • How to split string with trailing empty strings in result?
  • Scala group by list of list and subtracts grouped values
  • Scala - Creating a function to produce Unary string or integer values
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org