mirror of
https://github.com/matrix-construct/construct
synced 2024-10-04 22:58:52 +02:00
ircd:🆑 Improve event wait related.
This commit is contained in:
parent
519d2e3f45
commit
e403565029
1 changed files with 27 additions and 6 deletions
33
ircd/cl.cc
33
ircd/cl.cc
|
@ -493,6 +493,11 @@ try
|
||||||
assert(this->handle);
|
assert(this->handle);
|
||||||
assert(ptr);
|
assert(ptr);
|
||||||
|
|
||||||
|
// Perform the unmapping on unwind. This is after the mapping event
|
||||||
|
// completed and the closure was called below. The unmapping event will
|
||||||
|
// replace the event handle for this exec instance until its actual dtor;
|
||||||
|
// thus the lifetime of the exec we are constructing actually represents
|
||||||
|
// the unmapping event.
|
||||||
const unwind unmap{[this, &data, &q, &ptr]
|
const unwind unmap{[this, &data, &q, &ptr]
|
||||||
{
|
{
|
||||||
assert(!this->handle);
|
assert(!this->handle);
|
||||||
|
@ -508,6 +513,16 @@ try
|
||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
// After the closure is called below, or throws, or if wait() throws,
|
||||||
|
// we free the completed map event here to allow for the unmap event.
|
||||||
|
const unwind rehandle{[this]
|
||||||
|
{
|
||||||
|
assert(this->handle);
|
||||||
|
call(clReleaseEvent, cl_event(this->handle));
|
||||||
|
this->handle = nullptr;
|
||||||
|
}};
|
||||||
|
|
||||||
|
// Wait for the mapping to complete before presenting the buffer.
|
||||||
wait();
|
wait();
|
||||||
closure(const_buffer
|
closure(const_buffer
|
||||||
{
|
{
|
||||||
|
@ -587,6 +602,13 @@ try
|
||||||
);
|
);
|
||||||
}};
|
}};
|
||||||
|
|
||||||
|
const unwind rehandle{[this]
|
||||||
|
{
|
||||||
|
assert(this->handle);
|
||||||
|
call(clReleaseEvent, cl_event(this->handle));
|
||||||
|
this->handle = nullptr;
|
||||||
|
}};
|
||||||
|
|
||||||
wait();
|
wait();
|
||||||
closure(mutable_buffer
|
closure(mutable_buffer
|
||||||
{
|
{
|
||||||
|
@ -1089,6 +1111,11 @@ ircd::cl::work::work(void *const &handle)
|
||||||
ircd::cl::work::~work()
|
ircd::cl::work::~work()
|
||||||
noexcept try
|
noexcept try
|
||||||
{
|
{
|
||||||
|
const unwind free{[this]
|
||||||
|
{
|
||||||
|
call(clReleaseEvent, cl_event(handle));
|
||||||
|
}};
|
||||||
|
|
||||||
wait();
|
wait();
|
||||||
}
|
}
|
||||||
catch(const std::exception &e)
|
catch(const std::exception &e)
|
||||||
|
@ -1108,12 +1135,6 @@ ircd::cl::work::wait()
|
||||||
if(!handle)
|
if(!handle)
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
const unwind free{[this]
|
|
||||||
{
|
|
||||||
call(clReleaseEvent, cl_event(handle));
|
|
||||||
handle = nullptr;
|
|
||||||
}};
|
|
||||||
|
|
||||||
char buf[4] {0};
|
char buf[4] {0};
|
||||||
const int status
|
const int status
|
||||||
{
|
{
|
||||||
|
|
Loading…
Reference in a new issue