Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ConditionVariable.wait with predicator #27

Closed
samchon opened this issue Dec 12, 2018 · 0 comments
Closed

ConditionVariable.wait with predicator #27

samchon opened this issue Dec 12, 2018 · 0 comments
Labels
C++11 enhancement New feature or request
Projects

Comments

@samchon
Copy link
Owner

samchon commented Dec 12, 2018

TSTL had not implemented ConditionVariable class to use predicator in wait functions. At next update, they're need to be implemented.

namespace std
{
    export class ConditionVariable
    {
        public wait(): Promise<void>;
        public async wait(predicator: Predicator): Promise<void>
        {
            while (!await predicator())
                await this.wait();
        }

        public wait_for(ms: number): Promise<boolean>;
        public wait_for(ms: number, predicator: Predicator): Promise<boolean>;

        public wait_until(at: Date): Promise<boolean>;
        public async wait_until(at: Date, predicator: Predicator): Promise<boolean>
        {
            while (!await predicator())
                if (!await this.wait_until(at))
                    return await predicator();
            return true;
        }
    }
}
type Predicator = () => boolean | Promise<boolean>;
@samchon samchon added enhancement New feature or request C++11 labels Dec 12, 2018
@samchon samchon added this to To do in v2.1 Update via automation Dec 12, 2018
@samchon samchon moved this from To do to On review in v2.1 Update Dec 12, 2018
@samchon samchon moved this from On review to Done in v2.1 Update Dec 12, 2018
@samchon samchon closed this as completed Dec 12, 2018
@samchon samchon moved this from Done to Patch in v2.1 Update Feb 12, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C++11 enhancement New feature or request
Projects
No open projects
v2.1 Update
  
Patch
Development

No branches or pull requests

1 participant