~marcustomlinson/unity-scopes-api/scope_process_lifetime

« back to all changes in this revision

Viewing changes to include/unity/scopes/internal/RegistryObject.h

  • Committer: Marcus Tomlinson
  • Date: 2014-03-13 07:55:44 UTC
  • Revision ID: marcus.tomlinson@canonical.com-20140313075544-5tg03wrhs1swna96
Reduced mutexes in RegistryObject::ScopeProcess to a single process_mutex_ to better safety-proof and simplify concurrent request handling.

Show diffs side-by-side

added added

removed removed

Lines of Context:
82
82
        ScopeProcess(ScopeProcess const& other);
83
83
 
84
84
        std::string scope_id() const;
85
 
        ProcessState state() const;
86
85
        bool wait_for_state(ProcessState state, int timeout_ms) const;
87
86
 
88
87
        void exec();
91
90
        bool on_process_death(pid_t pid);
92
91
 
93
92
    private:
94
 
        void update_state(ProcessState state);
 
93
        // the following methods must be called with process_mutex_ locked
 
94
        void in_lock_update_state(ProcessState state);
 
95
        bool in_lock_wait_for_state(std::unique_lock<std::mutex>& lock,
 
96
                                    ProcessState state, int timeout_ms) const;
 
97
        void in_lock_kill(std::unique_lock<std::mutex>& lock);
95
98
 
96
99
    private:
97
 
        ScopeExecData exec_data_;
 
100
        const ScopeExecData exec_data_;
98
101
        ProcessState state_ = Stopped;
99
 
        mutable std::mutex state_mutex_;
 
102
        mutable std::mutex process_mutex_;
100
103
        mutable std::condition_variable state_change_cond_;
101
104
        core::posix::ChildProcess process_ = core::posix::ChildProcess::invalid();
102
 
        std::mutex process_mutex_;
103
105
    };
104
106
 
105
107
private: