How to send messages in the order they were queued, while ensuring that client B does not have to wait until client A has received his message?

I have a simplified producer/consumer pattern implemented below. The code outputs:

“A”

1 second delay

“B”

1 second delay

“A”

1 second delay

“B”

What approach can I take here to get rid of the 1-second delay between different letters?

What I’m looking for is something like

“A”

“B”

1 second delay

“A”

“B”

It’s important, that clients A and B receive the messages in the order the messages were queued in, but I do not want other clients to be blocked while processing for one client takes a really long time. Using two BlockingCollections and two consumer threads is not an option, because the user count is dynamic.

using System; using System.Collections.Concurrent; using System.Threading.Tasks;  namespace ConsumerProducer {     public enum ClientId     {         A,         B     }      class WebSocketMessage     {         public ClientId ClientId { get; }          public WebSocketMessage(ClientId clientId)         {             ClientId = clientId;         }          public async Task LongRunningSend()         {             Console.WriteLine(ClientId);             await Task.Delay(TimeSpan.FromSeconds(1));         }     }      class Program     {         public static BlockingCollection<WebSocketMessage> Messages = new BlockingCollection<WebSocketMessage>();          static async Task Main(string[] args)         {             var consumer = Task.Run(async () =>             {                 foreach (var message in Messages.GetConsumingEnumerable())                 {                     await message.LongRunningSend();                 }             });              ClientId clientId = ClientId.B;             while (true)             {                 // Flip between A and B                 clientId = clientId == ClientId.A ? ClientId.B : ClientId.A;                  Messages.Add(new WebSocketMessage(clientId));                  await Task.Delay(TimeSpan.FromMilliseconds(100));             }         }     } } 

Which is more motivating to continue a process until completion: a percentage, or the number of steps?

I’m working on a set of guides to help users learn how to use our app. We want to show which guides are available and some data with each guide indicating how far you’ve gotten. The idea is that if we show this information and constantly remind you of it, you’ll be more motivated to complete each one and learn more things about the app.

What we disagree on is how to format that information. Which is better: “You have completed 4/7 steps” vs “You have completed 57%”? Looking for data/metrics, not opinions.

Kubuntu 19.04 stuck with “Started waiting until snapd is fully seeded” for nearly 10 minutes

$   journalctl -u snapd.seeded.service --since today  -- Reboot -- jul 19 10:29:22 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 10:29:22 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 10:41:41 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 10:41:41 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 10:43:04 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 10:43:04 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 10:48:26 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 10:48:26 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 10:50:36 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 10:50:36 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 10:52:05 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 10:52:05 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 10:53:43 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 10:53:43 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 10:54:46 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 10:54:46 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 10:58:07 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 10:58:07 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 11:11:38 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 11:11:38 pc systemd[1]: Stopped Wait until snapd is fully seeded. - Reboot -- jul 19 11:25:49 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 11:25:49 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 11:32:03 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 11:32:03 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 10:58:07 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 10:58:07 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 11:11:38 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 11:11:38 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 11:14:41 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 11:14:41 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 11:20:14 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 11:20:14 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 11:25:49 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 11:25:49 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 11:32:03 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 11:32:03 pc systemd[1]: Stopped Wait until snapd is fully seeded. -- Reboot -- jul 19 11:37:40 pc systemd[1]: Starting Wait until snapd is fully seeded... jul 19 11:37:40 pc systemd[1]: Started Wait until snapd is fully seeded. jul 19 11:40:27 pc systemd[1]: snapd.seeded.service: Succeeded. jul 19 11:40:27 pc systemd[1]: Stopped Wait until snapd is fully seeded. 

Internet keeps dropping but wifi stays connected until I try to select network again

I am using ubuntu 18.04 on a Lenovo IdeaPad 330 Every so often (once in 10 minutes), I lose internet connectivity. Wifi still stays connected as indicated by the status on notification bar.New pages don’t open and existing requests are delayed.

When I go to the Status area and click on wifi> select network, it magically returns. I donot have to reconnect, or change network.

Just going to top right corner->Wifi SSID Name-> Select Network and cancel reconnects the Internet.

I am using ubuntu 18.04

 Qualcomm Atheros QCA9377 802.11ac Wireless Network Adapter (rev 31) 

How to efficiently move the decimal point in a number until reaching some threshold [migrated]

Say I have a double x, whose value is > 0 and < 1 million. I want to move its decimal point left until it is > 1 million and < 10 million. So for example, 23.129385 becomes 2313938.5.

What I’m doing now is just multiplying by 10 until reaching the stopping condition. However I’m performing this algorithm a lot so if I can optimize it somehow it would be helpful. A constant time solution, irrelevant of the magnitude of x, is obviously ideal but so far I haven’t been able to come up with one.

Steam and Ubuntu: support until 2025 and 20.04 LTS

Heavy steam clients that run the video gaming customer on Ubuntu devices remained in for a stun when Canonical, Ubuntu’s moms and dad business, revealed that this would not assistance 32-bit yalla shoot live streaming bundles on Ubuntu moving forward. Shutoff Software application, moms and dad business from Heavy steam, exposed that Heavy steam would not assistance Ubuntu any more once the modification landed which Shutoff would not suggested Ubuntu either any more.

Ubuntu has been the just Linux circulation that Heavy steam sustained formally up up until currently. While Heavy steam functions great on many various other Linux distributions, Shutoff would not deal any type of assistance if Heavy steam wasn‘t operate on Ubuntu.

The going down from 32-bit bundles from Ubuntu would position major difficulties for Heavy steam moving forward. Shutoff keeps in mind that the Heavy steam customer needs 32-bit collections and while Shutoff may have the ability to repair that in time, Linux individuals would discover quickly afterwards that countless video games would not play any more because they needed 32-bit atmospheres.

steam-linux-windows video game compatibility

Heavy steam depends on specific elements that have to be offered on the systems the software application is operate on, and a few of these occur to be 32-bit.

There’s a great deal much more to the technological and non-technical factors behind our issues, however all-time low line is that we would have needed to decrease what we are doing and scramble to assistance the brand-new plan in time for 19. 10. We were not positive we might do that without death a few of the churn to our individuals, and this would not resolve the issues for third-party software application beyond Heavy steam whereupon a lot of our individuals depend.

Canonical, as a reaction, released a declaration where this revealed that the following Ubuntu launches, 19. 10 and 20. 04 LTS, would consist of ” chose 32-bit i386 bundles “. The business strategies to include the neighborhood to discover which 32-bit bundles are had to run tradition software application and video games.

For mid-term, Canonical wishes to ” deal with the WINE, Ubuntu Workshop and video gaming neighborhoods to usage container innovation to deal with the supreme finish from life from 32-bit collections “.

The business keeps in mind that this had a number of inspirations for the choice to decrease 32-bit bundles consisting of that these get restricted screening which many Spectre and Meltdown mitigations are not offered for 32-bit systems.

Shutoff Software application, while admitting that it‘s not ” thrilled ” regarding the elimination from current performance, stated that this welcomes the prepare which this appears most likely that the business can ” remain to formally assistance Heavy steam on Ubuntu ” consequently.

The business strategies to take a look at circulation assistance moving forward and thinks about functioning ” better with a lot more circulation maintainers in the future “.

Assistance for Ubuntu 20. 04 LTS finishes in 2025 at the earliest. Shutoff enhanced video game assistance on Linux just recently by presenting a brand-new include called Heavy steam Play which brings much more Home windows video games to Linux.

How to translate increasing headache until unconsciousness into mechanical effects?

I have an idea for a homebrew cursed item for the whole party. (As a way to not let the party split up)

Every party member gets a non-removable ring on their thumb, or a tattoo, or a scar, or some other non-spell-slot thingy that can not be removed. This thing does give everyone a bonus of +2 initiative, so it’s worth something to the characters.

But my question is about the negative effect, being a cursed item after all.

Whenever the party is spread out too wide, each member gets a headache which worsens the more spread out the party is.

What is a good way stat-wise to implement this effect, if you have five steps for distance (500 ft per step), where the first step would be like a slight migraine, and the fifth step would lead to unconsciousness / a coma for 24 hours?

So far I was thinking of the following stacking effects:

  • 0: no effect (members are not farther than 500 ft apart from each other)
  • 1: WIS -2, Perception -3 (headache makes it hard to focus on your surroundings)
  • 2: INT -2, Perception -2 (thoughts are constantly occupied with enduring the pain)
  • 3: CHA -2, Perception -2 (pain is too strong to keep your wits)
  • 4: CON -4, STR -2, DEX -2 (constant pain is almost unbearable)
  • 5: daily CON check against 15. When it fails, player is unconscious for 24 hours. On success, the player can be awake for eight hours before falling unconscious.

Would these stat changes be reasonable to mirror real-life effects?

Computer that can’t upgrade beyond Windows 1803 – safe to use until when?

I have an old computer that can’t (at least according to Windows Update) upgrade beyond Windows 1803. (Probably due to the manufacturer not releasing updates to drivers.) Until when will it be safe to use?

This seems a little strange to me. In the past, Windows versions had a pretty long life. At least as far as security updates were concerned. It seems as if now with Windows 10, computers have a much shorter life expectancy due to lack of drivers combined with Microsoft treating the updates as something everyone is expected to do, though in reality it’s not possible. Am I missing something here?

palindromes with integers by adding numbers until a palindrome is reached- java

I’m not necessarily trying to ask for code but I’m not sure where I’m going wrong with this or why my current code is printing 10. Can someone help me understand where I’m going wrong.

 public static int palindroCount(int n){     String pal=n+"";     String lap="";     int count=-1;     for (int i=pal.length()-1; i>0; i--){         lap+=pal.substring(i,i+1);     }     if (pal.equals(lap)) {         count = 0;     } else {         while ((!pal.equals(lap)) && count<10){             pal=n*2+"";             for (int i=pal.length()-1; i>0; i--){                 lap+=pal.substring(i,i+1);             }             count++;         }     }     return count;     //This is wrong and I have no idea on how to get it. It prints out 10,      //when it's supposed to print 2 }  public static void main(String[] args) {     test2Prep model= new test2Prep();     System.out.println(model.palindroCount(159)); } 

The question in the textbook is: Given a positive integer n, return the number of p-additions needed to make it a palindrome. A p-addition is the addition of the number to its inverse. Ex, if n=159, the first p-addition yields: 159+951=1110. The second p-addition yields: 1110+ 0111=1221, which is a palindrome, so the return is 2. if n is a palindrome to begin with return 0, and if the number doesn’t become a palindrome after 10 p-additions then return -1.