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

Add SharedFuture #29

Open
MBkkt opened this issue Jul 16, 2021 · 1 comment · May be fixed by #182
Open

Add SharedFuture #29

MBkkt opened this issue Jul 16, 2021 · 1 comment · May be fixed by #182
Assignees
Labels
enhancement New feature good first issue Good for newcomers
Milestone

Comments

@MBkkt
Copy link
Member

MBkkt commented Jul 16, 2021

First of feel free to ask me(@MBkkt) any questions about this task, often the task may not be described in enough detail for devs who don't have the full context.

Make T SharedFuture<T>::Get() const;
"Allocate" the mutex inside the SharedFuture class, not on the stack as is the case with T Future::Get() &&

@MBkkt MBkkt added the enhancement New feature label Jul 16, 2021
@MBkkt MBkkt added this to the CSC deadline milestone Jul 16, 2021
@MBkkt MBkkt added this to To Do in Future/Promise via automation Jul 16, 2021
@MBkkt MBkkt modified the milestones: CSC deadline, Not main priority Aug 31, 2021
@Ri7ay Ri7ay self-assigned this Sep 12, 2021
@MBkkt
Copy link
Member Author

MBkkt commented Jan 15, 2022

auto tp = yaclib::MakeThreadPool(/*threads=CPU Cores*/);
auto strand = yaclib::MakeStrand(tp);
LRUCache<K, SharedFuture<V>> global_cache;

for (auto user : users) {
  auto future = yaclib::Run(tp, [&] -> K {
    return GetRequest(user);
  });
  shared_future = future.Then(strand, [&] (K key) {
    if (global_cache.has(key)) {
      return global_cache[key];
    }
    return global_cache[key] = yaclib::Split(yaclib::Run(tp, [] (K key) {
      return ComputeValue(key);
    }));
  });
  shared_future.Then(tp, [&] (const V& val) { MakeResponse(user, val); });
}

@MBkkt MBkkt assigned mkornaukhov03 and unassigned Ri7ay Aug 6, 2022
@MBkkt MBkkt linked a pull request Aug 6, 2022 that will close this issue
@MBkkt MBkkt modified the milestones: Release 2, Release 2022.09.01 Aug 6, 2022
@MBkkt MBkkt added the good first issue Good for newcomers label Aug 6, 2022
@MBkkt MBkkt moved this from To Do to In Progress in Future/Promise Aug 6, 2022
@MBkkt MBkkt removed this from In Progress in Future/Promise Aug 6, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature good first issue Good for newcomers
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants