fix order device -> scheduler (#1039)

This commit is contained in:
Awni Hannun 2024-04-26 13:46:41 -07:00 committed by GitHub
parent 5bfe89bdb1
commit 67d1894759
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -24,7 +24,9 @@ struct StreamThread {
std::thread thread;
StreamThread(Stream stream)
: stop(false), stream(stream), thread(&StreamThread::thread_fn, this) {}
: stop(false), stream(stream), thread(&StreamThread::thread_fn, this) {
metal::new_stream(stream);
}
~StreamThread() {
synchronize(stream);
@ -37,7 +39,6 @@ struct StreamThread {
}
void thread_fn() {
bool initialized = false;
while (true) {
std::function<void()> task;
{
@ -50,15 +51,6 @@ struct StreamThread {
q.pop();
}
// thread_fn may be called from a static initializer and we cannot
// call metal-cpp until all static initializers have completed. waiting
// for a task to arrive means that user code is running so metal-cpp
// can safely be called.
if (!initialized) {
initialized = true;
metal::new_stream(stream);
}
task();
}
}