GithubHelp home page GithubHelp logo

pollster's Introduction

pancake

A personal C++ utility library for a variety of uses

What does it do?

pancake includes many pieces of boilerplate code that are common throughout my software including:

Why the name 'pancake'?

I don't know. I searched "random words" online and 'pancake' was the first thing I saw. I'm not very inventive when it comes to names.

pollster's People

Contributors

atul9 avatar daxpedda avatar kprotty avatar memoryruins avatar striezel avatar tokarevart avatar zesterer avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

pollster's Issues

How is this different from futures::executor::block_on ?

The functionality provided by this crate is identical to futures::executor::block_on .

I have the following natural questions that I feel deserve to be mentioned in the readme:

What are the differences between the two versions?
If I already depend on futures with the executor feature, is there any reason to prefer pollster over futures?
If pollster is preferred in that case, why isn't the futures version implemented through pollster?

I'm aware that the readme broaches this topic to some degree t but I feel that the futures crate version deserves special mention because it is not (?) a heavy weight executor part of a larger async framework.

Deadlock

I had a quick look at it. It does have an unsafe without comment clarifying why it's guaranteed to be safe, which is unfortunate. On performance, it seems to be in the same league as async_std::task::block_on.

Now for the bad news, this deadlocks, and it doesn't on async_std::task::block_on, nor on futures::executor::block_on:

use
{
   std   :: { thread, sync::atomic::{ AtomicUsize, Ordering::SeqCst } } ,
   tokio :: { sync::mpsc                                              } ,
};


// queue size for the bounded channel, 16 is same as actix default size.
//
const BOUNDED : usize = 16;
const MESSAGES: usize = 100_000;


fn main()
{
   let (mut a_tx, mut a_rx) = mpsc::channel( BOUNDED );
   let (mut b_tx, mut b_rx) = mpsc::channel( BOUNDED );


   let thread_a = thread::spawn( move ||
   {
      pollster::block_on( async
      {
         while let Some( msg ) = a_rx.recv().await
         {
            b_tx.send( msg ).await.expect( "send on b" );
         }
      });
   });


   let thread_b = thread::spawn( move ||
   {
      pollster::block_on( async move
      {
         for _ in 0..MESSAGES
         {
            a_tx.send( () ).await.expect( "Send on a" );
         }
      });
   });


   pollster::block_on( async move
   {
      let sum = AtomicUsize::new(0);

      while sum.fetch_add( 1, SeqCst ) < MESSAGES
      {
         b_rx.recv().await;
      }

      assert_eq!( sum.load( SeqCst), MESSAGES + 1 );
   });


   thread_a.join().expect( "join thread_a" );
   thread_b.join().expect( "join thread_b" );
}

Some proper testing is in order I think. Good luck.

pollster 0.2.4 doesn't build on stable

Building a crate which indirectly depends on pollster suddenly started failing with the 0.2.4 release:

error[E0658]: use of unstable library feature 'wake_trait'
  --> /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.2.4/src/lib.rs:19:27
   |
19 |     task::{Context, Poll, Wake, Waker},
   |                           ^^^^
   |
   = note: see issue #69912 <https://github.com/rust-lang/rust/issues/69912> for more information

error[E0658]: use of unstable library feature 'wake_trait'
   --> /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.2.4/src/lib.rs:104:5
    |
104 | /     fn wake(self: Arc<Self>) {
105 | |         self.notify();
106 | |     }
    | |_____^
    |
    = note: see issue #69912 <https://github.com/rust-lang/rust/issues/69912> for more information

error[E0658]: use of unstable library feature 'wake_trait'
   --> /home/andrew/.cargo/registry/src/github.com-1ecc6299db9ec823/pollster-0.2.4/src/lib.rs:103:6
    |
103 | impl Wake for Signal {
    |      ^^^^
    |
    = note: see issue #69912 <https://github.com/rust-lang/rust/issues/69912> for more information

error: aborting due to 3 previous errors

For more information about this error, try `rustc --explain E0658`.
error: could not compile `pollster`

Please yank 0.2.4 and release it as 0.3.0 instead, as this appears to be a breaking change..

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.