[SERVER-25201] allow setting a Status on TaskExecutor::EventState Created: 21/Jul/16  Updated: 06/Dec/22  Resolved: 28/Jul/16

Status: Closed
Project: Core Server
Component/s: Networking, Sharding
Affects Version/s: None
Fix Version/s: None

Type: Improvement Priority: Major - P3
Reporter: Esha Maharishi (Inactive) Assignee: [DO NOT USE] Backlog - Sharding Team
Resolution: Won't Fix Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Assigned Teams:
Sharding
Participants:

 Description   

Rationale:

To make Events more useful (and more akin to regular event programming), they should be able to report the status of the Event they were tracking.

Possible implementation:

  • Add a Status field to TaskExecutor::EventState
  • Add a TaskExecutor::setEventStatus(const EventHandle& event, Status status) method (that takes the same lock as TaskExecutor::waitForEvent) to set the EventState's status
  • Make TaskExecutor::waitForEvent(const EventHandle& event) return the eventState's Status:

void ThreadPoolTaskExecutor::waitForEvent(const EventHandle& event) {
    invariant(event.isValid());
    auto eventState = checked_cast<EventState*>(getEventFromHandle(event));
    stdx::unique_lock<stdx::mutex> lk(_mutex);
    while (!eventState->isSignaledFlag) {
        eventState->isSignaledCondition.wait(lk);
    }
+    return eventState->status
}



 Comments   
Comment by Andy Schwerin [ 22/Jul/16 ]

Perhaps we should Gona step further and make Event more like std::future, and give them a typed return value.

Generated at Thu Feb 08 04:08:32 UTC 2024 using Jira 9.7.1#970001-sha1:2222b88b221c4928ef0de3161136cc90c8356a66.