FLTK logo

Re: [fltk.coredev] RFC: Fl::enable_locks()

FLTK matrix user chat room
(using Element browser app)   FLTK gitter user chat room   GitHub FLTK Project   FLTK News RSS Feed  
  FLTK Apps      FLTK Library      Forums      Links     Login 
 All Forums  |  Back to fltk.coredev  ]
 
Previous Message ]New Message | Reply ]Next Message ]

Re: RFC: Fl::enable_locks() Albrecht Schlosser Apr 20, 2021  
 
On 4/17/21 2:25 PM Michael Sweet wrote:
Another crazy option: just have Fl::lock() be a no-op if the run loop is not active and then have Fl::run() call Fl::lock() unconditionally. When threading is enabled (which should be all the time now) the right thing happens without any special initialization, and Fl::lock()/unlock() can continue to be used for synchronization as before.

The new (1.4) code examples can explain this change and existing code will continue to work.

Mike and others,

I thought again about your suggestion. Although I'm sure that we must not make Fl::lock() and Fl::unlock() no-ops if the run loop is not active this model could still work *if* we wanted to enable locking *unconditionally* in all FLTK applications.

(1) Fl::lock() and Fl::unlock() must always be functional, even before Fl::run() is called.

(2) We increment and decrement our own internal lock counts in Fl::lock() and Fl::unlock(), resp.

(3) At the entry of Fl::run() we check if Fl::lock() is effective (internal lock count > 0) and if not, call Fl::lock() internally only once when Fl::run() starts the loop.

(4) The internal unlock/wait/lock mechanism would not need to be changed but would always be effective, even in single-threaded programs.

This way old code that calls Fl::lock() works as before and code that does not call Fl::lock() would still use unlock/lock internally and could use threads with FLTK locking etc.

That said, I think it's possible to do, but I'd still vote for leaving everything as-is, i.e. do not force single-threaded apps to do internal locking.

--
You received this message because you are subscribed to the Google Groups "fltk.coredev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to fltkcoredev+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/fltkcoredev/d72fb06d-9bb6-f503-e07b-a7b7cf70f0c3%40online.de.
Direct Link to Message ]
 
     
Previous Message ]New Message | Reply ]Next Message ]
 
 

Comments are owned by the poster. All other content is copyright 1998-2024 by Bill Spitzak and others. This project is hosted by The FLTK Team. Please report site problems to 'erco@seriss.com'.