WrapEarnPass left a comment (geany/geany#4620)

Ooh. I have some indication that std::future is bork because of gtk.

I ripped the EditView.cxx out and replaced it with a fob off to gio.
```
                        const bool textUnicode = CpUtf8 == 
model.pdoc->dbcsCodePage;
                        const bool multiThreaded = threads > 1;
                        printf("threads:%d\r\n",threads);
                        const bool multiThreadedContext = multiThreaded || 
callerMultiThreaded;
                        IPositionCache *pCache = posCache.get();
#if GTK
                        GThreadPool* threadpool = g_thread_pool_new (   
baked_cb,   NULL,  threads,   TRUE,   NULL );
                        for (size_t th = 0; th < threads; th++) {
                                printf("%s %s:%d\r\n",__func__, __FILE__, 
__LINE__);
                                DecorationData  *decoration = g_slice_new 
(DecorationData);
                                decoration->pCache=pCache;
                                decoration->surface=surface; 
                                decoration->vstyle=&vstyle; 
                                decoration->ll=&ll;
                                decoration->segments=&segments;
                                decoration->nextIndex=&nextIndex;
                                decoration->textUnicode=textUnicode;
                                decoration->multiThreaded=multiThreadedContext;
                                g_thread_pool_push(threadpool,decoration,NULL);
                        }
                        g_thread_pool_free(threadpool, FALSE, TRUE);
                        printf("%s %s:%d\r\n",__func__, __FILE__, __LINE__);
#else
                        // If only 1 thread needed then use the main thread, 
else spin up multiple
                        const std::launch policy = (multiThreaded) ? 
std::launch::async : std::launch::deferred;
                        printf("policy:%s\r\n",(multiThreaded) ? 
"std::launch::async" : "std::launch::deferred");
                        std::vector<std::future<void>> futures;
                        for (size_t th = 0; th < threads; th++) {
                                printf("%s %s:%d\r\n",__func__, __FILE__, 
__LINE__);
                        // Find relative positions of everything except for tabs
                        std::future<void> fut = std::async(policy,
                                [pCache, surface, &vstyle, &ll, &segments, 
&nextIndex, textUnicode, multiThreadedContext]() {
                                LayoutSegments(pCache, surface, vstyle, ll, 
segments, nextIndex, textUnicode, multiThreadedContext);
                        });
                        futures.push_back(std::move(fut));
                        }
                        for (const std::future<void> &f : futures) {
                                printf("%s %s:%d\r\n",__func__, __FILE__, 
__LINE__);
                                                 f.wait();
                        }
#endif
                }

```

I now have threads.
```
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:556
maxLayoutThreads:8
threads:8
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
LayoutLine /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:543
baked_cb /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:419
LayoutSegments /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:352
baked_cb /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:419
LayoutSegments /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:352
baked_cb /home/build/Projects/geany/geany/scintilla/src/EditView.cxx:419
```
No crashy. The std::future that I left in place for line wrapping: Still crashy.

@nyamatongwe et al: That isn't really my code. I pulled it from 
[gtk](https://docs.gtk.org/gio/class.Task.html) mostly. Still, if you need a 
release to play with it, It's contributed under GPL-2.0-or-later.

-- 
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/issues/4620#issuecomment-5035434713
You are receiving this because you are subscribed to this thread.

Message ID: <geany/geany/issues/4620/[email protected]>

Reply via email to