Hello,

I tried to compile  the Pushstream Example in the Spec: 706.5.1 Optimizing Event Creation.

I got a compile exception "Local variable may not have been initialized." in line


ses.connectPromise().then(onConnect);


could somebody tell me more about how to get run this snipped

----------------------------------------------------------------------------------------------------
PushStreamProvider psp = new PushStreamProvider();

SimplePushEventSource<Long> ses = psp.createSimpleEventSource(Long.class))

Success<Void,Void> onConnect = p -> {
    new Thread(() -> {
        long counter = 0;
        // Keep going as long as someone is listening
        while (ses.isConnected()) {
          ses.publish(++counter);
          Thread.sleep(100);
          System.out.println("Published: " + counter);
        }
        // Restart delivery when a new listener connects
        ses.connectPromise().then(onConnect);
      }).start();
    return null;
  };

// Begin delivery when someone is listening
ses.connectPromise().then(onConnect);

// Create a listener which prints out even numbers
psp.createStream(ses).
  filter(l -> l % 2L == 0).
  limit(5000L).

  forEach(f -> System.out.println("Consumed event: " + f));

------------------------------------------------------------------------------------------------

regards

_______________________________________________
OSGi Developer Mail List
osgi-dev@mail.osgi.org
https://mail.osgi.org/mailman/listinfo/osgi-dev

Reply via email to